Closed sovoereign closed 3 years ago
If you look at this example https://github.com/crossbario/autobahn-java#websocket-on-android
Everytime your server sends a message, the onMessage
callback will be called. So in your code, please make sure you have the onMessage
callback.
@om26er Yes I have onMessage callback, but receiving a response when I connect to the server
if(!connection.isConnected()){
connection.connect(getWssUrl(s_driver_api_key),otherStrings, new WebSocketConnectionHandler() {
@Override
public void onConnect(ConnectionResponse response) {
System.out.println("Connected to server-----"+response);
}
@Override
public void onOpen() {
System.out.println("Connection onOpen------");
}
@Override
public void onClose(int code, String reason) {
System.out.println("Connection closed------"+code);
System.out.println("Connection closed------"+reason);
}
@Override
public void onMessage(String payload) {
System.out.println("Received message:----- " + payload);
}
});
}else{
System.out.println("Connected:----- " );
}
[8,"driverXYZapikey",{"event":51,"booking":"7A1708ED","message":"Booking #7A1708ED on 29 September - 16:39 was updated. Please check new details."}]
Receiving this message on the browser, not receiving in socket
Is the websocket server public, maybe I can try to reproduce the issue (and debug, if needed). Is it possible for you to share the websocket URI ?
I want to receive message continuously, i can send message but not receiving after establishing connection but working fine with browser.
sometime showing in onPing
method
onPing isBinary:----- [B@dc3be9c
There is something very odd happening here. The server that you are trying to connect talks WAMPv1, this library now only supports WAMPv2. So I'd say this is a lost cause.
To elaborate on that. Autobahn Java only support WAMP protocol version 2. However, the server that you are trying to connect is only talks WAMP protocol version 1. Here is the screenshot of the errors. You can clearly see your server response returns this specific line in its response headers.
Sec-WebSocket-Protocol: wamp
@om26er okay got your point, but why does socket connect?
the websocket opening handshake fails, since the websocket subprotocol negotiation runs into a mismatch. use a wamp2 server or use plain websocket
I can receive a message when I connect to the socket. Once I connected to the socket, my server responds whenever something happens so how will I receive a message continuously.