androidwebrtckurento

Not able connect Native Android device to kurento Media server


I have started developing live streaming using kurento media server. I have Installed kurento media server in Ubuntu 14.04TLS. It gets successfully Installed and also started successfully. I have used STUN server, I have uncommented these two lines

 stunServerAddress=<stun_ip_address>
 stunServerPort=<stun_port>

And used IP, PORT as follows: 173.194.66.127:19302 .After doing all these thing I started kurento media server and it gets started. Now I create Android native application by implementing RoomListener Interface. Here is the Code to connect with Kurento Media Server.

public class MainActivity extends AppCompatActivity implements RoomListener {
        private LooperExecutor executor;
        private static KurentoRoomAPI kurentoRoomAPI;
        private String TAG = "MainActivity";
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            executor = new LooperExecutor();
            executor.requestStart();
            String wsRoomUri = "wss://173.194.66.127:19302/room";
            kurentoRoomAPI = new KurentoRoomAPI(executor, wsRoomUri, this);
            kurentoRoomAPI.connectWebSocket();
        }
        @Override
        public void onRoomResponse(RoomResponse response) {
            Log.d(TAG, "Response");
        }
        @Override
        public void onRoomError(RoomError error) {
            Log.d(TAG, "Error:  " + error.toString());
        }
        @Override
        public void onRoomNotification(RoomNotification notification) {
            Log.d(TAG, "Notification Received");
        }
        @Override
        public void onRoomConnected() {
            Log.d(TAG, "Connected");
        }
        @Override
        public void onRoomDisconnected() {
            Log.d(TAG, "Room Disconnected");
        }

    }

But when I run the application, it shows the following error:

Process: com.base.videostreamingkurento, PID: 1880


java.lang.AssertionError: java.net.SocketTimeoutException: failed to connect to /173.194.66.127 (port 19302) after 90000ms
                                                                          at libcore.io.IoBridge.connect(IoBridge.java:117)
                                                                          at java.nio.SocketChannelImpl.connect(SocketChannelImpl.java:199)
                                                                          at org.java_websocket.client.WebSocketClient.interruptableRun(WebSocketClient.java:210)
                                                                          at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:188)
                                                                          at java.lang.Thread.run(Thread.java:818)
                                                                       Caused by: java.net.SocketTimeoutException: failed to connect to /173.194.66.127 (port 19302) after 90000ms
                                                                          at libcore.io.IoBridge.connectErrno(IoBridge.java:189)
                                                                          at libcore.io.IoBridge.connect(IoBridge.java:127)
                                                                          at libcore.io.IoBridge.connect(IoBridge.java:115)

Solution

  • It seems that you have a little confusion with your deployment and IPs. You are trying to connect, from your client, to the STUN server. Instead, try setting the IP and PORT where your app server is located in this line

    String wsRoomUri = "wss://APP_SERVER_IP:8443/room";
    

    If you can draw that down, you'll see more clearly where everything goes and what should connect to what.