I have made a multiplayer real-time game for Facebook messenger. It’s taken a year to develop thus far! It is finished, all except for this problem.
I am facing this intermittent, Facebook messenger for Android, specific problem.
I get a 1006 error, but only ever in some android devices, and only ever in the actual Facebook messenger app for Android.
at first I thought it’s a Facebook messenger glitch. However, it can’t be, because connecting to echo.websocket.org works every time. (I mean if i simply switch out my “wss://URL:port” for “echo.websocket.org”).
The thing is, a websocket 1006 error is a client specific error. What makes this even more confusing and impossible to debug, is that sometimes it works. When it does work, it usually continues to work for up to a day. Often it only works for a few hours. Then all of a sudden it stops working, and starts showing the 1006 error again.
Before i change host provider, i wanted to ask anyone here. Obviously this requires someone who really understands exactly how the websocket protocol works.
These are the things you need to know;
- 1: The only time it doesn’t work, is through Facebook messenger, and only on an android device. It happens more in a galaxy tab A than in a galaxy S series 6 upwards.
- 2: It works fine in ios, mac and pc, all the time.
- 3: It works on android through a web browser every time.
- 4: I have tried changing from websocket to socket.io, so i could run the socket.io debugger on my server. No debug output ever shows during this specific problem.
- 5: When I change the connection to echo.websocket.org it always works.
- 6: I am connecting using a URL and port. ie wss://myUrl.com:portnumber.
- 7: I have tried creating a proxy to a port on my server so i could remove the port number and mimic the “wss://echo.websocket.org” (no port num) “wss://myUrl.com”.
- 8: I have contacted my hosting provider and they say that there
should be nothing preventing it from working. “Because it works through ios, mac and pc, it must be a facebook messenger problem”,
- 9: Sometimes it works, when it does, it stays working for a random amount of time.
- 10: It wont ever break when it is working.
- 11: Facebook direct support for instant game developers have looked into it, and they say, “Because echo.websocket.org works, it has to be a problem with your code”.
- 12: I have tried a pure vanilla websocket script and, although it worked at first, just like my game works sometimes, it stopped working after a random amount of time. When it stops working, I get the 1006 error again.
- 13: Sometimes clearing the messenger cache and pressing force stop solves the problem for a random amount of time. Other times it doesn’t.
- 14: There is no way to see the developer console in Facebook messenger so the only option is to use Eruda or vconsole. Neither of them catch websocket errors.
So this suggests that it is a server issue. Right? Even tho error 1006 says its specifically a client problem?
The only thing I haven’t tried is changing host providers. But, I have quite a powerful and expensive VPS, so changing hosts isn’t just something i want to do if possible.
This is clearly something that only an extremely experienced developer can answer. I just hope there is one here?
Thanks in advance.