Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket Closed when stop() #48

Open
KeithLaiKB opened this issue Oct 5, 2021 · 3 comments
Open

Socket Closed when stop() #48

KeithLaiKB opened this issue Oct 5, 2021 · 3 comments

Comments

@KeithLaiKB
Copy link

KeithLaiKB commented Oct 5, 2021

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.

@KeithLaiKB
Copy link
Author

KeithLaiKB commented Jan 6, 2022

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);
}

@szysas
Copy link
Contributor

szysas commented Jan 7, 2022

Hi @KeithLaiKB,

How about checking against "ocket closed"? This was we would cover both cases.
Please feel free to make PR.

@KeithLaiKB
Copy link
Author

KeithLaiKB commented Jan 24, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants