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

Exception in MQTTClient #72

Closed
ralphwetzel opened this issue Jan 19, 2023 · 7 comments
Closed

Exception in MQTTClient #72

ralphwetzel opened this issue Jan 19, 2023 · 7 comments

Comments

@ralphwetzel
Copy link
Contributor

image

No further debugging possible, no further info available.

@phoddie
Copy link
Owner

phoddie commented Jan 19, 2023

Hard to say what might be going on from the limited information. That exception should never happen in normal operation. My best guess is that the socket disconnected and the driver noticed but the disconnect notification hasn't reached the higher software layer. Does it seem possible that either the server connection or Wi-Fi connection was lost in this case?

One solution would be for the MQTT client to catch the exception and close the socket. That will solve the problem for MQTTT but not other users of the TCP socket. A more general solution is to treat the unexpected write failure as notification that the socket connection is lost, fail silently here, and report the error through the usual onError callback. That would behave as-if the disconnect notification had arrived. Silently failing the write doesn't change anything -- a write made immediately before the socket disconnects might not be delivered either.

@phoddie
Copy link
Owner

phoddie commented Jan 19, 2023

FWIW – reporting via onError is a small change:

	if (ERR_OK != tcp_write_safe(tcp->skt, buffer, needed, TCP_WRITE_FLAG_COPY | TCP_WRITE_FLAG_MORE)) {
		xsTrace("tcp write failed");
		tcpTrigger(tcp, kTCPError);
		return;
	}

@ralphwetzel
Copy link
Contributor Author

ralphwetzel commented Jan 19, 2023

Does it seem possible that either the server connection or Wi-Fi connection was lost in this case?

There was no indication of any major (in the sense of cable disconnected or other systems had noticed & reported) loss of connection.

report the error through the usual onError callback

My view: Priority should be, to catch the exception. Reporting back via onError sounds reasonable. Then the library or the node should handle this onError report and recover accordingly.

Hard to say what might be going on from the limited information

I know. Unfortunately xsbug tends (on my systems) to close the debug status in such situations when you try to expand the tree data in the left hand panels...

@phoddie
Copy link
Owner

phoddie commented Jan 19, 2023

Unfortunately xsbug tends to crash in such situations when you try to expand the tree data in the left hand panels

Never seen that. If you have a way to reproduce that, please open an issue.

There was no indication of any major (in the sense of cable disconnected or other systems had noticed & reported) loss of connection.

OK. Networks are unreliable, so seemingly random failures do happen. The non-determinism makes diagnosing these issues challenging.

@phoddie
Copy link
Owner

phoddie commented Jan 19, 2023

Changes committed to SDK TCP implementations for macOS, Linux, and embedded (lwip) targets. Will propagate to public Moddable SDK repository by week's end.

@ralphwetzel
Copy link
Contributor Author

Unfortunately xsbug tends to crash in such situations when you try to expand the tree data in the left hand panels

Never seen that. If you have a way to reproduce that, please open an issue.

Done.

@phoddie
Copy link
Owner

phoddie commented Jan 27, 2023

Exception resolved in TCP module. Closing.

@phoddie phoddie closed this as completed Jan 27, 2023
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