我正在使用Socket.Io开发一个Android应用程序。当我使用我的本地IP地址(192.168.1.22:4000)时,我从服务器上得到了限制。但是当我使用域名(“http://mydomainname.com:80)时我得到io.socket.SocketIOException:握手时出错Exception如何处理这个问题。请检查下面的代码>提前谢谢。
JSONObject js = new JSONObject();
js.put("key",value);
js.put("key",value);
socket = new SocketIO();
socket = new SocketIO("http://mydomain.com:80");
socket.addHeader("id", 20);
socket.connect(new IOCallback()
{
@Override
public void onMessage(JSONObject json, IOAcknowledge ack)
{
// TODO Auto-generated method stub
System.out.println(".....onMessage.......");
}
@Override
public void onMessage(String data, IOAcknowledge ack)
{
// TODO Auto-generated method stub
System.out.println(".....onMessage... STR....");
}
@Override
public void onError(SocketIOException socketIOException)
{
// TODO Auto-generated method stub
}
@Override
public void onDisconnect()
{
// TODO Auto-generated method stub
}
@Override
public void onConnect()
{
// TODO Auto-generated method stub
System.out.println("....connected ....");
}
@Override
public void on(String event, IOAcknowledge ack, Object... args)
{
// TODO Auto-generated method stub
Object[] arguments = args;
JSONObject jsb = (JSONObject) arguments[0];
} catch (JSONException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
},js,"event name");
} catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}