Android Question Issues receiving through websockets

kostefar

Active Member
Licensed User
Longtime User
Dear All,

I´ve been playing with the client from:

https://www.b4x.com/android/forum/threads/websocket-client-library.40221/

I have not set up the B4j side of it, cause I´m not going to run a local server for this, but attempt to connect to a remote one.

So I´m testing it against:

http://demos.kaazing.com/echo/

Which shows me as connected, but when sending text, nothing comes back.

All I did in the client was changing the link to:

B4X:
Private link As String = "ws://demos.kaazing.com:80/echo/"

What could be the reason for this?

Thanks in advance!
 

DonManfred

Expert
Licensed User
Longtime User
Are you sure it (the WS) runs on port 80?
Or maybe the issue is that the ws-Server is a Node.JS Server.
Are you trying to use the WS from within a Webpage using Javascript? (this should work)
Or maybe you need to run a B4J WS-Server to connect to
 
Last edited:
Upvote 0

kostefar

Active Member
Licensed User
Longtime User
Hi DonManfred, thanks for this.
I tried both with and without port 80 as part of the link, and as mentioned, I do indeed get "Connected" but not more.

There´s another websocket library here, that I also tried with the same result, where somebody succesfully tested it against echo.websocket.org, which is the URL that redirects to the one in my initial post.
https://www.b4x.com/android/forum/threads/securewebsocket-client-library.45981/#post-283911
I don´t know of course in which way he was succesful.. maybe just confirmed to have made a connection.
This website however is for testing a connection and getting an echo back showing that it works.

Could it be that the ServerTime event is not where such a received message should show up, but that I need to add another event somewhere..?
I´m assuming that there are no ports that need to be opened on my side as long as I´m just using the client side, right?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

kostefar

Active Member
Licensed User
Longtime User
Ok, it´s now obvious that I´m not having the right event set up to capture traffic. I just tried looking in my network monitor at the traffic going in and out, and indeed the ws server replies as it should, but b4a does not show it. So, If servertime is not the event where incoming messages are showing, then what should it be?

Edit:
Fixed! I added log (msg) to Private Sub ws_TextMessage(msg As String) and it finally shows me what´s going on on the incoming side + I get the logic of what´s going on now!
 
Last edited:
Upvote 0
Top