· Zen HuiFer · Tutorial  · 1 min read

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.

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

ProtocolPort
WebSocket13332
MQTT1883 8083 8084 8883 18083
COAP5683
TCP/IP3332

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;
    }
}


Back to Blog

Related Posts

View All Posts »
Device Access via COAP

Device Access via COAP

This article details how to use the COAP protocol to access devices on the Go IoT development platform, including access procedures, code examples, and precautions to help developers quickly get started and achieve efficient device access.

TCP/IP Access Device

TCP/IP Access Device

This article details how to use the TCP/IP protocol to access devices in the Go IoT development platform, including access processes, authentication methods, and data transmission examples, helping developers quickly get started and achieve efficient device access.

WebSocket Access Device

WebSocket Access Device

This article details how to access devices through WebSocket in the Go IoT development platform, including login authentication and client creation steps, suitable for IoT developers.

MQTT Client Management Solution

MQTT Client Management Solution

This article details the solution for designing and managing a large number of MQTT clients in IoT projects, including constraints, solution design, load balancing, and failover, helping developers optimize system performance and ensure stable operation.