java-coap
java-coap copied to clipboard
Socket Closed when stop()
when I try to test the example java-coap/coap-core/src/test/java/protocolTests/ClientServerTest.java (https://github.com/PelionIoT/java-coap/blob/master/coap-core/src/test/java/protocolTests/ClientServerTest.java)
case: when server.stop() or client.stop(), the console would show "java.net.SocketException: socket closed"
process: when I traced this process, I found it sources from DatagramSocketTransport.stop() method and LOGGER.error(e.getMessage(), e); in the method, the code line about "TransportExecutors.shutdown(readingWorker);" in this method couldn't run.
Should we deal with it or need to ignore it.
when I tried to change the "Socket closed" to "socket closed" in com.mbed.coap.transport.udp.DatagramSocketTransport, it seems that it could solve this problem, but I don't know whether this change is what the contributor want.
source: com.mbed.coap.transport.udp.DatagramSocketTransport
if (!ex.getMessage().startsWith("Socket closed")) { LOGGER.warn(ex.getMessage(), ex); }
Hi @KeithLaiKB,
How about checking against "ocket closed"? This was we would cover both cases.
Please feel free to make PR.
Hi @KeithLaiKB,
How about checking against "
ocket closed"? This was we would cover both cases. Please feel free to make PR.
I think it could be ok if (!ex.getMessage().contains("ocket closed")), it might work, but it might also be the potential risk in the future. in my opinion, if (!ex.getMessage().startsWith("Socket closed")&& !ex.getMessage().startsWith("socket closed")) would be better.