异常:java.net.SocketException: Method sendUrgentData() is not supported
2017-06-21 19:19
483 查看
Runnable keepBeatingRunnable=new Runnable() { @Override public void run() { while (isConnected){ System.out.println("心跳开始"); try{ Thread.sleep(10000); System.out.println("心跳开始2"); sslSocket.sendUrgentData(0xFF); System.out.println("发送心跳包"); }catch (Exception e){ isConnected=false; System.out.println("心跳开始3"); e.printStackTrace(); //sendJsonMsg(MessageTool.mkOfflienJSMsg(userID,getMID())); } System.out.println("心跳开始4"); } } };
输出异常:
查了一下API:
SslSocket从Socket继承了这个方法,然而并不能实现。
我的解决方法是依赖keepalive方法,但是这个时间间隔又特别长。
查了一下似乎找不到可以有效更改这个时间的方法,至少在SSLSocket住上是不行的,大部分都是Method is not support。
最后我自己写了个心跳线程,很是蛋疼。这个问题先Mark,以后解决了再来处理。
public void run(){ while (!ConnectionOver){ try{ //System.out.println("BEATING Start"); sendBeat(); Thread.sleep(1000*60); }catch (Exception e){ ConnectionOver=true; e.printStackTrace(); } } //System.out.println("BEATING over"); }
相关文章推荐
- Android异常总结--- java.net.SocketTimeoutException: Transport endpoint is not connected
- Android异常总结--- java.net.SocketTimeoutException: Transport endpoint is not connected
- Android异常总结---1.Android java.net.SocketException: Address family not supported by protocol
- Android异常总结---1.Android java.net.SocketException: Address family not supported by protocol
- request time failed: java.net.SocketException: Address family not supported by protocol 解决办法
- java.net.SocketTimeoutException: Transport endpoint is not connected
- 配置zookeeper异常 Error contacting service. It is probably not running.以及java.net.ConnectException: 拒绝连接
- 使用javamail出现java.net.SocketException: Network is unreachable: connect异常 解决方法
- java.net.SocketException: Address family not supported by protocol family: connect
- java.net.SocketException: Address family not supported by protocol
- request time failed: java.net.SocketException: Address family not supported by protocol
- 使用javamail出现java.net.SocketException: Network is unreachable: connect异常 解决方法
- Spring 整合 Flex (BlazeDS)无法从as对象 到 Java对象转换的异常:org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.Date' to required type 'java.sql.Timestamp' for property 'wfsj'; nested exception is java.lang.Ill
- Android java.net.SocketException: Address family not supported by protocol 出错提示
- 解决 java.net.SocketException: sendto failed: ECONNRESET (Connection reset by peer) 异常
- activemq 异常 Failed to start ActiveMQ JMS Message Broker. Reason: java.net.SocketException: No such device
- java.net.SocketException: Software caused connection abort: recv failed 异常分析
- System.NotSupportedException: Specified method is not supported(update xml in GridView)
- Android异常java.io.FileNotFoundException:(Is a directory)
- Tomcat的异常 之 java.lang.IllegalArgumentException: Document base *** does not exist or is not a readabl