Android Question WebSocket problem

giada

Member
Sometimes i find difference between wsh.ws.connected and the real webs state...

I have 2 webs : 1 always open for rx
1 open only for tx and then closed

For both sometimes i find wsh.ws.connected = true but is not real so if i wsh.SendEventToServer it is not send and i can't understand to call wsh.connect
And diffrently if i call wsh.connect and the wsh is already connected i have a crash....

I've tried different way but i don't resolve it.

This is what i find in the log:


I attach my WebSocket File
 

Attachments

  • WebSocket.bas
    26.4 KB · Views: 322

Erel

B4X founder
Staff member
Licensed User
Longtime User
Code is too large for me to say anything about it.

1. Make sure to use the latest version (2.11).
2. I've checked the library code. It should report the correct state, assuming that the network driver reports it correctly.

It is possible that you are seeing an intermittent state where the Closed event was raised but the internal socket is still connected.
Try it with:
B4X:
Log(wsh.ws.connected)
Sleep(100)
Log(wsh.ws.connected)
 
Upvote 0