Uploaded image for project: 'ActiveMQ Artemis'
  1. ActiveMQ Artemis
  2. ARTEMIS-4961

How to solve mqtt connection over websocket when visiting from Wide Area Network IP ?

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Cannot Reproduce
    • 2.17.0, 2.24.0
    • None
    • Broker, MQTT
    • None

    Description

      broker.xml:

      <acceptor name="wss">tcp://0.0.0.0:1883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true</acceptor>

      testPage.html:

      <!DOCTYPE html>
      <html lang="en">  
         <head>
            <meta charset="UTF-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0" />
            <title>MQTT over WebSocket</title>
            <script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>   
         </head>   
         <body>   
         </body>  
         <script>        
            const clientId = 'mqttjs_' + Math.random().toString(16).substring(2, 8)  
            const connectUrl = 'ws://218.106.xxxxx:1883'     //Wide Area Network IP
            const options = {       
               keepalive: 30,      
               clientId: clientId,       
               clean: true,       
               connectTimeout: 5000,       
               username: 'test',      
               password: 'test',       
               reconnectPeriod: 1000    
         
            }     
            const topic = '/WebSocket/mqtt'     
            const payload = 'WebSocket mqtt test'    
            const qos = 0     
            console.log('connecting mqtt client')     
            const client = mqtt.connect(connectUrl, options)    
            client.on('connect', () => {
               console.log('Client connected:' + clientId)
               client.subscribe(topic, { qos }, (error) => {         
                  if (error) {           
                     console.log('Subscribe error:', error)           
                     return        
                  }         
                  console.log(`Subscribe to topic ${topic}`)      
               }
            ) 
         </script>
      </html>

       

      artemis.log:

      2024-07-30 13:34:25,017 WARN  [DefaultChannelPipeline:1152] An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer
      
      2024-07-30 13:40:12,587 WARN  [DefaultChannelPipeline:1152] An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer
      
      2024-07-30 13:55:59,399 WARN  [DefaultChannelPipeline:1152] An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

      Attachments

        Activity

          People

            jbertram Justin Bertram
            windynet windy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: