paho.mqtt.c icon indicating copy to clipboard operation
paho.mqtt.c copied to clipboard

Broken pipe exception

Open qinrhx opened this issue 1 year ago • 3 comments

Describe the bug I use the MQTTAsync library, when the network is closed, I receive a Broken pipe exception. I am very confused, because

  1. I call signal(SIGPIPE, SIG_IGN) in my program, and the return value is 1.
  2. 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

image

qinrhx avatar Aug 10 '23 05:08 qinrhx

What do you mean by "when the network is closed?" How are you performing a disconnect?

fpagliughi avatar Aug 10 '23 16:08 fpagliughi

What do you mean by "when the network is closed?" How are you performing a disconnect?

Turn off the computer's WiFi network

qinrhx avatar Aug 11 '23 02:08 qinrhx

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?

icraggs avatar Oct 01 '23 13:10 icraggs