androidwebsocketapprtc

WebSocket - Status Code 403 and status message - Forbidden


I am working on video call app using Apprtc.Follow below mention libraries.

  1. https://github.com/njovy/AppRTCDemo
  2. https://github.com/Piasy/AppRTC-Android

When I change url to my custom server instead of apprtc server then video call is disconnected after 1 minute. I have lost connection with server.

To avoid the connection lost with server, we need to ping server in regular interval approx 30 sec.

But above mention AppRTC project are using jar file(autobanh.jar) to websocket connection, but in library sendPing mentod is private so not accessible.

Question 1 - There is nay way to ping websocket server.

Try after replace websocet library I had changed websocket library with below mention libraries

  1. https://github.com/Koredotcom/android-kore-sdk/tree/master/BotsSDK/korebotsdklib/src/main/java/kore/botssdk/autobahn
  2. https://github.com/martindale/soundtrack.io-android/tree/master/src/de/tavendo/autobahn

After recplacing websocket library, Now I am able to access sendPing method. But still I have connection lost after 60 seconds during video call.

Ping Method-

 public void sendPingMessageToServer() {
    try {
        WebSocketMessage.Ping ping = new WebSocketMessage.Ping();
//            ping.mPayload="ping to server".getBytes();
        mWebSocketWriter.sendPing(ping);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

When in uncomment ping.mPayload line then I get BufferOverflowException.

Timer of 30 seconds

  private void startConnectionCheckTimer() {
    timerInstance.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            try {
               ws.sendPingMessageToServer();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }, 0, 30 * 1000);
}

Please suggest how to avoid call disconnection after 60 seconds.


Solution

  • I had changed the websocket library to https://github.com/crossbario/autobahn-java

    This library has functionality of auto ping to server on regular time interval. After adding it, i have modified only one class of ApprtcDemo- WebSocketChannelClient