· Zen HuiFer · Tutorial · 需要1 分钟阅读
Multi-protocol Support
This article introduces how to use WebSocket, MQTT, TCP/IP, COAP protocols for data transmission in the Go IoT development platform, and provides relevant port configuration and Nginx configuration examples to help developers better achieve multi-protocol support.
The default usage of WebSocket, MQTT, TCP/IP, COAP ports in the Go IoT development platform is as follows
Protocol | Port |
---|---|
WebSocket | 13332 |
MQTT | 1883 8083 8084 8883 18083 |
COAP | 5683 |
TCP/IP | 3332 |
If you need to configure Nginx, you can consider using the following content
- TCP/IP
stream{
upstream tcpserver {
server 0.0.0.0:3332;
}
server {
listen 22122;
proxy_pass tcpserver;
}
}
- WebSocket Nginx Configuration
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream sre_backend {
server 127.0.0.1:13332;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://sre_backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "$connection_upgrade";
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
- COAP
stream{
upstream coap_server {
server 0.0.0.0:5683;
}
server {
listen 15683 udp;
proxy_pass coap_server;
}
}