triniwiz / nativescript-socketio

Socket.IO for nativescript
Apache License 2.0
71 stars 31 forks source link

Client not ping & disconnect after 10 seconds #106

Open overbost opened 3 years ago

overbost commented 3 years ago

EDIT: gevent-websocket (enabling server websockets) partially resolve the issue. The client remain connected with ping/pong but "connect" event is fired twice. Polling transport option not work, like other options...

Make sure to check the existing issues in this repository

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

My socket.io server is a Flask application with this packages installed:

This is what append:

this is the flask log with client disconnection :

WebSocket transport not available. Install eventlet or gevent and gevent-websocket for improved performance.
 * Debugger is active!
 * Debugger PIN: 639-488-643
41bd89624c3447639ceb889fcf34c50b: Sending packet OPEN data {'sid': '41bd89624c3447639ceb889fcf34c50b', 'upgrades': [], 'pingTimeout': 60000, 'pingInterval': 25000}
--------- User connected
emitting event "connect" to 41bd89624c3447639ceb889fcf34c50b [/]
41bd89624c3447639ceb889fcf34c50b: Sending packet MESSAGE data 2["connect",{"data":"Connected"}]
41bd89624c3447639ceb889fcf34c50b: Sending packet MESSAGE data 0
192.168.1.102 - - [27/Jul/2021 16:06:34] "GET /socket.io/?platform=android&EIO=3&transport=polling HTTP/1.1" 200 -
41bd89624c3447639ceb889fcf34c50b: Received packet CLOSE data None
--------- User disconnected
192.168.1.102 - - [27/Jul/2021 16:06:44] "POST /socket.io/?EIO=3&transport=polling&platform=android&sid=41bd89624c3447639ceb889fcf34c50b HTTP/1.1" 200 -
192.168.1.102 - - [27/Jul/2021 16:06:44] "GET /socket.io/?EIO=3&transport=polling&platform=android&sid=41bd89624c3447639ceb889fcf34c50b HTTP/1.1" 200 -
97a2465155564f51ae970b3719a159da: Sending packet OPEN data {'sid': '97a2465155564f51ae970b3719a159da', 'upgrades': [], 'pingTimeout': 60000, 'pingInterval': 25000}

This is the Flask log whit browser client, OPTIONS call with ping and all work fine

192.168.1.110 - - [27/Jul/2021 16:29:31] "OPTIONS /socket.io/?EIO=3&transport=polling&t=NheNkLe HTTP/1.1" 200 -
0d780ef647cf480097868fdc4f0219ae: Sending packet OPEN data {'sid': '0d780ef647cf480097868fdc4f0219ae', 'upgrades': [], 'pingTimeout': 60000, 'pingInterval': 25000}
--------- User connected
emitting event "connect" to 0d780ef647cf480097868fdc4f0219ae [/]
0d780ef647cf480097868fdc4f0219ae: Sending packet MESSAGE data 2["connect",{"data":"Connected"}]
0d780ef647cf480097868fdc4f0219ae: Sending packet MESSAGE data 0
192.168.1.110 - - [27/Jul/2021 16:29:31] "GET /socket.io/?EIO=3&transport=polling&t=NheNkLe HTTP/1.1" 200 -
192.168.1.110 - - [27/Jul/2021 16:29:31] "OPTIONS /socket.io/?EIO=3&transport=polling&t=NheNkYF&sid=0d780ef647cf480097868fdc4f0219ae HTTP/1.1" 200 -
192.168.1.110 - - [27/Jul/2021 16:29:56] "OPTIONS /socket.io/?EIO=3&transport=polling&t=NheNqeu&sid=0d780ef647cf480097868fdc4f0219ae HTTP/1.1" 200 -
0d780ef647cf480097868fdc4f0219ae: Received packet PING data None
0d780ef647cf480097868fdc4f0219ae: Sending packet PONG data None
192.168.1.110 - - [27/Jul/2021 16:29:56] "GET /socket.io/?EIO=3&transport=polling&t=NheNkYF&sid=0d780ef647cf480097868fdc4f0219ae HTTP/1.1" 200 -
192.168.1.110 - - [27/Jul/2021 16:29:56] "POST /socket.io/?EIO=3&transport=polling&t=NheNqeu&sid=0d780ef647cf480097868fdc4f0219ae HTTP/1.1" 200 -
192.168.1.110 - - [27/Jul/2021 16:29:56] "OPTIONS /socket.io/?EIO=3&transport=polling&t=NheNqf4&sid=0d780ef647cf480097868fdc4f0219ae HTTP/1.1" 200 -

This is the app log event

JS: connected
JS: undefined
JS: connected
JS: connect
JS: error
JS: null
JS: disconnected
JS: transport error
JS: connected
JS: undefined
JS: connected
JS: connect

Is there any code involved?

The app is really basic:

        const socket = new SocketIO('http://192.168.1.110:5000?platform=android');

        socket.on("connect", (data)=>{
          console.log("connected")
          console.log(data)
        })
        socket.on("disconnect", (data)=>{
          console.log("disconnected")
          console.log(data)
        })

        socket.on("error", (data)=>{
          console.log("error")
          console.log(data)
        })

        socket.connect()
triniwiz commented 3 years ago

try @triniwiz/nativescript-socketio@4 an lmk

overbost commented 3 years ago

@triniwiz/nativescript-socketio@4

@triniwiz/nativescript-socketio requires at least version 7.0.0 of platform android. Currently installed version is 6.5.0.