Created an experimental channel in phoenix app, running on localhost, but can’t connect to it from my Android client, running in emulator. Everything is ok with channel, because JavaScript client, shipped with Phoenix, can connect and work with it.
Trying to connect to “ws://localhost:4000/socket/websocket”, as library docs suggest, but getting this error message: “java.net.ConnectException: Failed to connect to localhost/127.0.0.1:4000”.
As long as the android application has network access then just access the IP of the computer that is running the phoenix server and make sure phoenix binds to that IP (which it does by default in development mode).
It’s exactly the same as if testing any other networked app.
Seems, deserialization of server responses now causes a problem. I’m getting this error on Android: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "join_ref" (class org.phoenixframework.channels.Envelope), not marked as ignorable (4 known properties: "event", "ref", "payload", "topic"]), with this error message: Failed to read message payload
Basically, class Envelope expecting 4 properties, but gets 5 - the “join_ref” and fails on it. I tried to mark methods receiving "Envelop"s with Jacksons’ @JsonIgnoreProperties(ignoreUnknown = true), but it didn’t help. Suggestions are either to mark POJO class (Envelope, in this case) with it (don’t have access to it, as it comes with channels client lib), or configure ObjectMapper, but server response is mapped already, when it reaches to my code.
Yeah there is indeed a join_ref in the JSON (why is your namespace referencing xml?!?), so that seems like a bug in whatever channel library that is, should submit a bug report.