Skip to content

TCP not receiving conn:on("disconnection",...) following a conn.close() #1716

@eyaleb

Description

@eyaleb

Maybe not a bug.

This looks like a change due to the recent net reimplementation. It is uncommon for my app to reach this code so it took me a while to realise that this logic stopped working.

If this is an intended change, then the doco should probably highlight this. In short, this is a user visible change.

Expected behavior

Issuing a TCP conn:close() triggers a conn:on("disconnection", ....

Actual behavior

disconnection not triggered

Test code

My old code, which worked

conn:on("disconnection", function(conn, data)
	Log ("disconnected")
	do_file ("save")
end)

conn:on("receive", function(conn, data)
	Log ("received '%s'", data)
	conn:close()
end)

but now I need to do

conn:on("disconnection", function(conn, data)
	Log ("disconnected")
	-- does not normally happen
end)

conn:on("receive", function(conn, data)
	Log ("received '%s'", data)
	conn:close()
	do_file ("save")
end)

People who do not bother issuing the close() before a dsleep/restart will not see a problem.

NodeMCU version

Recent dev.

Hardware

Any.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions