kiwiirc / kiwibnc

Apache License 2.0
44 stars 14 forks source link

Report server listen errors to console #120

Closed ItsOnlyBinary closed 3 years ago

ItsOnlyBinary commented 3 years ago

Currently if there are any errors while listening on sockets they are not reported

this change will show errors like access denied or port in use in the console

note: the {...err, message: err.message} is because just passing err does not include the message for some reason

prawnsalad commented 3 years ago

The close event is always triggered after an error event which is why we include an error property in the connection.close event. https://github.com/kiwiirc/kiwibnc/blob/e8119b89c6b0def3c05badeae6ea7a476d5f21d6/src/sockets/socketserver.js#L111 However... it looks like I messed up there and I'm not storing lastError anywhere. So in your server error handler it should store the error to lastError and include it's message+name+code properties.

ItsOnlyBinary commented 3 years ago

I don't believe the close event is fired when it fails to open, i was trying to test my changes to exit codes in ubuntu and forgot about the <1024 port restrictions for normal users. was not getting an error in console and could not visit the login page.

prawnsalad commented 3 years ago

My bad, I was talking about client sockets, not a server socket. All good!