Android client, phoenix server

Hi.

I am working on a simple proof of concept. The business I work for has a series of products that have integrated screens which are driven by Android boxes. The android boxes are running this board:

I am able to enable USB debugging on this board and I have it connected to Android Studio on windows (OSX doesn’t connect properly via USB). The board is running Jellybean 4.2.2 and I am connecting to my phoenix websocket server using the following library:

For my proof of concept I am doing a simple task of sending messages from the server to my client boxes. Basically, I click a button on the webpage to change which video is playing on my clients. The clients receive the message and display the video… pretty simple… And it works, kinda. :slight_smile:

Bear with me, I am trying hard not to make this sound like an Android programming question!

Testing on my Google Pixel, it worked fine (its running Android 8.X). However when connecting to the Tismart board, it seems to stop responding to messages from the server and also loses the ability to send independent messages back to the server. In my android application, I added a button that when clicked, sends a message back to the server - which the server does nothing with other than displaying a message using IO.puts. I added that button for debugging purposes to see if it was at a specific time that it would stop sending messages.

I am also catching any exceptions I can in Android and displaying them on the screen, but there seems to be a few that suggest that the connection was “reset by peer”…

Is there a callback or some other part of the ecosystem that I can hook into to determine what is happening with my connections? Unfortunately, I can’t easily do that on the client as they are running Android 4.2.2 and that doesn’t support profiling using the Android studio tools.

BTW the other technique I have tried is to send a ping message from the server to the clients and then have the clients respond to that message. My theory was that if the connections were timing out then this would help keep them alive… I was doing this every 20 seconds…

2 Likes

BTW, all of the above issues were observed when testing locally. The server and client are running on the same network with no firewalls (that I know of) in between… There are definitely none on my computer, but I can’t be certain that the Android box has none. Although I wouldn’t expect it has one that is interferring with the connection as my system works for a short period of time (as described above) before becoming unresponsive.

Another observation I have made is that while my original theorising made it sound like the client was being disconnected from the server (although I have seen a connection reset by peer error), it seems more like the payloads are being held up in a queue of some sort / limited by something. When it seems that the client is no longer responsive I click the button on the screen of my client which sends a message to the server. One click, nothing happened on the server… So I click repeatedly… still nothing… until about 10 seconds later when a flood of debugging messages appear on the server saying that the button was clicked on the client. Again, both devices are running on the same network and pinging each machine on the command line returns times less that 10ms…

Any ideas of where I could look to make this respond reliably?

1 Like

Are you running on Android simulator? I think it cannot reach the local server.

1 Like

No, its not the simulator… i am running on the hardware I mentioned in my first post. Its a chinese android board.

I have since tried sending a heartbeat to the server as I thought that maybe the library I am using doesn’t do that. So that is my next port of call to make sure that they are working properly.

1 Like

I know the Android developer at my company has been having some issues with the Android Phoenix Channels and there are numerous open issues, including support for v2 of the wire protocol: https://github.com/eoinsha/JavaPhoenixChannels/issues/56

With that said we are successfully using the library in production for over a year now.

1 Like

Ok, good to know. Do you know what version of Android they are running? Other experts I have contacted suggested that early versions of Android had linux issues around the network communications where it would be a bit constipated when sending and receiving data on the network. But I don’t have enough knowledge about Android to confirm this.

1 Like

I just installed wireshark and noticed that my Android application was sending the heartbeat over and over… so I just tested on a wired connection and all is working fine… I wonder if Android 4.2.2 has particular issues regarding wifi communications. My application isn’t doing anything advanced with the radios… in fact it is doing nothing. Other than the most basic PhoenixJavaChannels demo…

1 Like

We’re developing a consumer mobile app so we support all sorts of mostly modern versions of Android.

Android 4.2.2 is quite old at this point and is no longer receiving patches: https://en.wikipedia.org/wiki/Android_version_history

If possible maybe you should try updating the version of Android that is running.

1 Like

Ok… I don’t think its a simple as updating as I think the board manufacturer releases custom Android builds… I have tried to get in contact with them to see what the latest version is that they will support.

1 Like

Yep, Android 4.2.2 is the latest I can have running on that board. I still haven’t finished learning elixir let alone writing a custom build of Android! I will just work within the constraints I have. Wired is currently working fine, I will find some expertise as to why wireless might not be working so well on my board.

1 Like