javascript - Vuzix M100 and Webrtc Error: connect failed: EHOSTUNREACH (No route to host) -


here szenario want reach:

i want develop 2 way remote video conference vuzix m100 (android api 15) , google chrome browser / alternatively firefox. in order reach connection i'm using webrtc , node.js server websockets enable lookup of 2 clients.

the problem i'm facing if connect 2 chrome browser clients in detail android device (sony xperia z 3 compact) , deskop pc works perfect. if try connect vuzix on browser i'm getting error there no route host.

node.js server:

  var fs = require('fs'); var https = require('https'); var privatekey  = fs.readfilesync('server.key', 'utf8'); var certificate = fs.readfilesync('server.crt', 'utf8');  var credentials = {key: privatekey, cert: certificate}; var express = require('express'); var app = express();  //require our websocket library  var websocketserver = require('ws').server;   var httpsserver = https.createserver(credentials, app); httpsserver.listen(9090);  //creating websocket server @ port 9090  // var wss = new websocketserver({port: 9090}, {});   var wss = new websocketserver({   server : httpsserver })   //all connected server users  var users = {};  //when user connects our sever  wss.on('connection', function(connection) {     console.log("user connected");     //when server gets message connected user     connection.on('message', function(message) {         var data;         //accepting json messages        try {           data = json.parse(message);        } catch (e) {           console.log("invalid json");           data = {};        }        //switching type of user message        switch (data.type) {           //when user tries login          case "login":              console.log("user logged", data.name);               //if logged in username refuse              if(users[data.name]) {                 sendto(connection, {                    type: "login",                    success: false                 });              } else {                 //save user connection on server                 users[data.name] = connection;                 connection.name = data.name;                  sendto(connection, {                    type: "login",                    success: true                 });              }               break;           case "offer":              //for ex. usera wants call userb              console.log("sending offer to: ", data.name);              //if userb exists send him offer details              var conn = users[data.name];               if(conn != null) {                 //setting usera connected userb                 connection.othername = data.name;                  sendto(conn, {                    type: "offer",                    offer: data.offer,                    name: connection.name                 });              }              break;           case "answer":              console.log("sending answer to: ", data.name);              //for ex. userb answers usera              var conn = users[data.name];               if(conn != null) {                 connection.othername = data.name;                 sendto(conn, {                    type: "answer",                    answer: data.answer                 });              }               break;            case "candidate":              console.log("sending candidate to:",data.name);              var conn = users[data.name];              if(conn != null) {                 sendto(conn, {                    type: "candidate",                    candidate: data.candidate                 });              }               break;           case "leave":              console.log("disconnecting from", data.name);              var conn = users[data.name];              conn.othername = null;               //notify other user can disconnect peer connection              if(conn != null) {                sendto(conn, {                    type: "leave"                });              }              break;           default:              sendto(connection, {                 type: "error",                 message: "command not found: " + data.type              });               break;        }     });      //when user exits, example closes browser window     //this may if still in "offer","answer" or "candidate" state     connection.on("close", function() {         if(connection.name) {           delete users[connection.name];            if(connection.othername) {              console.log("disconnecting ", connection.othername);              var conn = users[connection.othername];              conn.othername = null;              if(conn != null) {                 sendto(conn, {                    type: "leave"                 });              }          }        }     });       connection.send("hello world");   });  function sendto(connection, message) {     connection.send(json.stringify(message));  } 

android app:

public class serverconnection {     private websocketfactory websocketfactory;     private websocket ws;     private mediastream ms;     private peerconnectionfactory peerfactory;     private peerconnection yourconn;     private mediaconstraints sdpconstraints;     private sessionobserver sessionobserver = new sessionobserver();     private peerobserver peerobserver = new peerobserver();     private string connecteduser;      public serverconnection(mediastream ms, peerconnectionfactory peerfactory) {         this.websocketfactory = new websocketfactory();         this.ms = ms;         this.peerfactory = peerfactory;         // create custom ssl context.         sslcontext context = null;         try {             context = naivesslcontext.getinstance("tls");         } catch (nosuchalgorithmexception e) {             e.printstacktrace();         }         // set custom ssl context.         websocketfactory.setsslcontext(context);         initwebsockets();      }      public void sendmessage(string message) {         if (connecteduser != null) {             try {                 jsonobject json = new jsonobject(message);                 json.put("name", connecteduser);                 ws.sendtext(json.tostring());             } catch (jsonexception e) {                 e.printstacktrace();             }          } else {             log.e("string s", message);             ws.sendtext(message);          }     }      private void initwebsockets() {         try {             ws = websocketfactory.createsocket("wss://192.168.179.36:9090");             ws.addlistener(new socketlistener());             thread t = new thread(new runnable() {                 @override                 public void run() {                     try {                         ws.connect();                     } catch (websocketexception e) {                         e.printstacktrace();                         initwebsockets();                     }                 }             });             t.start();         } catch (ioexception e) {             e.printstacktrace();         }     }      class socketlistener extends websocketadapter {         @override         public void onconnected(websocket websocket, map<string, list<string>> headers) throws exception {             log.e("connected", "connected");             jsonobject json = new jsonobject();             try {                 // für den anfang statisch                 json.put("type", "login");                 json.put("name", "john");             } catch (jsonexception e) {                 e.printstacktrace();             }             sendmessage(json.tostring());         }           @override         public void onconnecterror(websocket websocket, websocketexception exception) throws exception {             log.e("onerror", exception.getmessage());         }           @override         public void ondisconnected(websocket websocket,                                    websocketframe servercloseframe, websocketframe clientcloseframe,                                    boolean closedbyserver) throws exception {         }          @override         public void ontextmessage(websocket websocket, string text) throws exception {             log.e("got message", text);             jsonobject json = new jsonobject(text);             if (json != null) {                 switch (json.getstring("type")) {                     case "login":                         log.e("condition", json.getstring("success"));                         handlelogin(json.getboolean("success"));                         break;                     case "offer":                         handleoffer(json.getstring("offer"), json.getstring("name"));                         break;                     case "answer":                         handleanswer(json.getstring("answer"));                         break;                     case "candidate":                         string candidate = json.getstring("candidate");                         handlecandidate(candidate);                         break;                     case "leave":                         break;                     default:                         break;                 }             }         }           @override         public void onframesent(websocket websocket, websocketframe frame) throws exception {             log.e("sent", frame.getpayloadtext());         }     }       private void handlelogin(boolean success) {         if (!success) {             log.e("handlelogin", "try different username");         } else {             list<peerconnection.iceserver> server = new arraylist<>();             server.add(new peerconnection.iceserver("stun:stun2.1.google.com:19302"));             server.add(new peerconnection.iceserver("turn:192.158.29.39:3478?transport=udp", "28224511:1379330808", "jzeoet2v3qb0y27grntt2u2paya="));             sdpconstraints = new mediaconstraints();             sdpconstraints.optional.add(new mediaconstraints.keyvaluepair("offertoreceiveaudio", "true"));             sdpconstraints.optional.add(new mediaconstraints.keyvaluepair("offertoreceivevideo", "true"));              yourconn = peerfactory.createpeerconnection(server, sdpconstraints, peerobserver);             log.e("media stream:", ms.tostring());             yourconn.addstream(ms);              // wird später implementiert um anrufe zu starten             // yourconn.createoffer(new sessionobserver(), sdpconstraints);         }     }       private void handleoffer(string offer, string name) {         try {             jsonobject sdp = new jsonobject(offer);              connecteduser = name;             sessiondescription sessiondescription = new sessiondescription(sessiondescription.type.offer, sdp.getstring("sdp"));             yourconn.setremotedescription(sessionobserver, sessiondescription);              yourconn.createanswer(sessionobserver, sdpconstraints);         } catch (jsonexception e) {             e.printstacktrace();         }      }       private void handleanswer(string answer) {         try {             log.e("answer", answer);             jsonobject sdp = new jsonobject(answer);             sessiondescription sessiondescription = new sessiondescription(sessiondescription.type.answer, sdp.getstring("sdp"));             yourconn.setremotedescription(sessionobserver, sessiondescription);         } catch (jsonexception e) {             e.printstacktrace();         }     }       private void handleleave() {     }      private void handlecandidate(string candidate) {         log.e("handlecandidate", candidate);          //yourconn.addicecandidate(new icecandidate()) //        try { //            jsonobject candidatejson = new jsonobject(); //            candidatejson.put("type", "candidate"); //            jsonobject candidateinfosjson = new jsonobject(candidate); //            candidatejson.put("candidate", candidateinfosjson); // //            sendmessage(candidatejson.tostring()); //        } catch (jsonexception e) { //            e.printstacktrace(); //        }     }       class peerobserver implements peerconnection.observer {         @override         public void onsignalingchange(peerconnection.signalingstate signalingstate) {             log.e("onsignalingchange", "");         }          @override         public void oniceconnectionchange(peerconnection.iceconnectionstate iceconnectionstate) {             log.e("oniceconnectionchange", "");          }          @override         public void oniceconnectionreceivingchange(boolean b) {             log.e("oniceconnectionchange", "");         }          @override         public void onicegatheringchange(peerconnection.icegatheringstate icegatheringstate) {             log.e("onicegatheringchange", "");         }          @override         public void onicecandidate(icecandidate icecandidate) { //            log.e("onicecandidate", icecandidate.tostring()); //            jsonobject candidate = new jsonobject(); //            try { // //                candidate.put("type", "candidate"); //                candidate.put("label", icecandidate.sdpmlineindex); //                candidate.put("id", icecandidate.sdpmid); //                candidate.put("candidate", icecandidate);             log.e("onicecandidate", "here");   //            } catch (jsonexception e) { //                e.printstacktrace(); //            }          }          @override         public void onaddstream(mediastream mediastream) {             log.e("onaddstream", "stream added: " + mediastream);          }          @override         public void onremovestream(mediastream mediastream) {             log.e("onremovestream", "removed mediastream: " + mediastream);         }          @override         public void ondatachannel(datachannel datachannel) {             log.e("ondatachannel", "");         }          @override         public void onrenegotiationneeded() {             log.e("onrenegotiationneeded", "");         }      }       class sessionobserver implements sdpobserver {          @override         public void oncreatesuccess(sessiondescription sessiondescription) {             log.e("session", "sending");             jsonobject session = new jsonobject();             jsonobject answer = new jsonobject();             try {                 string answeroroffer = sessiondescription.type.tostring().tolowercase();                 session.put("type", answeroroffer);                 answer.put("type", answeroroffer);                 answer.put("sdp", sessiondescription.description);                 session.put(answeroroffer, answer);                 log.e("session", session.tostring());                 //session.put(answeroroffer, sessiondescription.description);                  sendmessage(session.tostring());             } catch (jsonexception e) {                 e.printstacktrace();             }          }          @override         public void onsetsuccess() {             log.e("do call success", ".....");         }          @override         public void oncreatefailure(string s) {             log.e("do call failure", s);          }          @override         public void onsetfailure(string s) {             log.e("onsetfailure", s);          }     }  } 

important mention error appers in initwebsockets function

the error get:

    09-22 15:41:47.056 7682-7779/com.mobile_function.webrtc_android w/system.err: com.neovisionaries.ws.client.websocketexception: failed connect '192.168.179.36:9090': failed connect /192.168.179.36 (port 9090): connect failed: ehostunreach (no route host) 09-22 15:41:47.056 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ com.neovisionaries.ws.client.socketconnector.doconnect(socketconnector.java:119) 09-22 15:41:47.056 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ com.neovisionaries.ws.client.socketconnector.connect(socketconnector.java:81) 09-22 15:41:47.064 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ com.neovisionaries.ws.client.websocket.connect(websocket.java:2022) 09-22 15:41:47.064 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ com.mobile_function.webrtc_android.serverconnection$1.run(serverconnection.java:84) 09-22 15:41:47.064 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ java.lang.thread.run(thread.java:856) 09-22 15:41:47.064 7682-7779/com.mobile_function.webrtc_android w/system.err: caused by: java.net.connectexception: failed connect /192.168.179.36 (port 9090): connect failed: ehostunreach (no route host) 09-22 15:41:47.071 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ libcore.io.iobridge.connect(iobridge.java:114) 09-22 15:41:47.071 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ java.net.plainsocketimpl.connect(plainsocketimpl.java:192) 09-22 15:41:47.071 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ java.net.plainsocketimpl.connect(plainsocketimpl.java:459) 09-22 15:41:47.071 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ java.net.socket.connect(socket.java:842) 09-22 15:41:47.071 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ com.neovisionaries.ws.client.socketconnector.doconnect(socketconnector.java:110) 09-22 15:41:47.071 7682-7779/com.mobile_function.webrtc_android w/system.err:   ... 4 more 09-22 15:41:47.071 7682-7779/com.mobile_function.webrtc_android w/system.err: caused by: libcore.io.errnoexception: connect failed: ehostunreach (no route host) 09-22 15:41:47.079 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ libcore.io.posix.connect(native method) 09-22 15:41:47.079 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ libcore.io.blockguardos.connect(blockguardos.java:85) 09-22 15:41:47.079 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ libcore.io.iobridge.connecterrno(iobridge.java:127) 09-22 15:41:47.079 7682-7779/com.mobile_function.webrtc_android w/system.err:     @ libcore.io.iobridge.connect(iobridge.java:112) 09-22 15:41:47.079 7682-7779/com.mobile_function.webrtc_android w/system.err:   ... 8 more 

i have searched in topics these error codes. wifi connection enabled , can go different webpages on mozilla firefox vuzix glass cant reach server.

the 2 clients definitively in same subnet: android: 192.168.179.94 html server webapp: 192.168.179.36:8080 node-socket server: 192.168.179.36:9090 gateway: 192.168.179.1

i hope can give me advices how solve problem

kind regards

jmd

solved problem. link helped me fix problem: http://forum.airdroid.com/discussion/379/i-can-t-even-ping-my-phone

kind regards john


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -