paho.mqtt.c
paho.mqtt.c copied to clipboard
Broken pipe exception
Describe the bug I use the MQTTAsync library, when the network is closed, I receive a Broken pipe exception. I am very confused, because
- I call signal(SIGPIPE, SIG_IGN) in my program, and the return value is 1.
- I triggered by the NOSIGPIPE compile definition and re-compile the library, but prompt that SO_NOSIGPIPE is not defined,maybe my system does not support this parameter.
I would like to know what could be the reason for this and is there any way to fix it?
paho.mqtt.c version :the master branch. os version: ubuntu 20.04 64 bit
What do you mean by "when the network is closed?" How are you performing a disconnect?
What do you mean by "when the network is closed?" How are you performing a disconnect?
Turn off the computer's WiFi network
The library calls signal(SIGPIPE, SIG_IGN); too, in Socket.c. Without this lots of applications would be getting SIGPIPE. Apparently SO_NOSIGPIPE is BSD only, so doesn't exist in Linux.
Make sure there isn't another call to signal which resets the behavior?
The Linux doc says that sigaction is preferred. So maybe you could try that to see if that changes anything?