Closed ezizrehimov closed 3 years ago
Please use the latest version of this lib. Draft_10 got removed a long time ago.
Best regards, Marcel
okay i now used latest version and delete here Draft_10. But now i getting error
Error: Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
WebSocketClient mWs = new WebSocketClient(new URI("ws://168.119.56.105/radioapi/ws")) {
@Override
public void onMessage(String message) {
try {
JSONObject
obj = new JSONObject(message);
String channel = obj.getString("channel");
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onOpen(ServerHandshake handshake) {
System.out.println("opened connection");
}
@Override
public void onClose(int code, String reason, boolean remote) {
System.out.println("closed connection");
}
@Override
public void onError(Exception ex) {
ex.printStackTrace();
}
};
mWs.connect();
// JSONObject obj = new JSONObject();
// obj.put("event", "addChannel");
// obj.put("channel", "ok_btccny_ticker");
// String message = obj.toString();
//send message
// mWs.send(message);
mWs.close();
}
I now added slf4j.jar file , now i getting this error:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
closed connection
how i can System.out.println() println this webscoket api response?
Oh okay. i now find problem. how i can add authentication (login,password) ?
client.addHeader("Authorization","Basic " + basicAuth);
I know do this. But i still get this error :
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
This just a warning, not an error. You won't be able to turn on logging, but everything else will still work.
thank you.
How i can read websocket api json format in Java Desktop App? i added your jar file and tryed this, but this only doing closed connection. My webscoket api url : ws://168.119.56.105/radioapi/ws