Android Question How to trouble shoot websocket connection problem.

IslandMedic

Member
Licensed User
Longtime User
Happy Holidays to all!

Environment:
Amazon AWS server running Ratchet/PHP websocket server with port 8080 open on the server.
Home internet with a Galaxy Tab and a windows pc running the b4a. I am using wifi to bridge to the tablet.

Problem:
I created a simple b4a app with a starter service and the provided websocket class to open a connection to the server and sit waiting for communications. The out going connection gets made, as I can see the connection notice on the server, but the reply back to the app doesn't fire the connected event on the app.

I am temped to post my code here and have you tell me whats wrong, but I don't learn that way. What I am asking for is some trouble shooting techniques.

I am thinking that this is a firewall/router issue at my end here at home. I have forwarded ports I have used DMZ I have done a bunch of things. just trying to figure out some testing ideas to diagnose the issue.

I am struggling as well with one piece of code. I am trying to understand the callback and event name process.

B4X:
'Starter Service
Sub Connect 'send init connect to server
    wsh.Initialize(Me, "wsh")
    wsh.Connect(serverlink)
End Sub

'Websocket Class
Public Sub Initialize (vCallback As Object, vEventName As String)
    CallBack = vCallback
    EventName = vEventName
    ws.Initialize("ws")
End Sub

thanks

Brad
 

IslandMedic

Member
Licensed User
Longtime User
So I decided to go back to the beginning. I was trying not to use the java based server provided here as I don't know java and wanted to use the Php based Ratchet. Well I have decided once I looked at the java server that I think I should stick with something that works out of the box and then extend from there. The Ratchet product is just not well supported for the beginner. I have had some success but have hit a bump.

run Java server on my local windows pc and can connect to it via a browser and via my tablet using the stock push client. All works great! Nice to have success finally.

complied the non mysql server into a jar and unloaded it to my Amazon AWS. I opened the 8080 port to allow incoming connections. ran the server with "java -jar server.jar". I got this warning

2015-12-22 17:57:31.735:WARNejh.MimeTypes:main: java.util.MissingResourceException: Can't find bundle for base name org/eclipse/jetty/http/encoding, locale en_US

But the server runs.

I can connect to the server with my android tablet from my home wifi and I have a connected message and the server shows the connection as well. Using b4a client

when I try to connect to the server with my browser on my pc and cell phone ( www.knorrfamily.org:8080/push ) I get.

B4X:
HTTP ERROR: 404
Problem accessing /push. Reason:

Not Found


Powered by Jetty://

The server logs show me this:

70.66.152.31 - - [22/Dec/2015:18:03:43 +0000] "GET /push HTTP/1.1" 404 282 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"



Any thoughts as to what is happening? Can anyone else connect to this address?

Brad
 
Last edited:
Upvote 0

IslandMedic

Member
Licensed User
Longtime User
ok I found the answer, when you deploy the java server, you have to include the www directory from the project folders. It DOES NOT get included when you compile the app and send it up to the server. Took some digging but I found it. Now to learn java and make the server work for me.

whew!

Brad
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…