-
Notifications
You must be signed in to change notification settings - Fork 176
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
Add a user specified timeout parameter to TCP sockets #245
Comments
EDIT: After further testing, this only works on the initial connection. Auto reconnects do not honor this setup. Looking deeper I see that connectAuto must be modified also. That works. Temporery solution only. A hack not a fix. FWIW: the timeout parameter of the Socket.connect() call is only a timeout for the connect sequence. If the connection is not made before the timeout occurs... An idle timeout on an active connection requires a little more configuration. I modified mqtt_client_mqtt_server_normal_connection: connect override: add this code at the top of the Socket.connect().then(){} section
FOR MACOS: this code addition provides the expected timeout when the server abruptly disconnects from the network. |
I didn't think to check the raw socket options, thanks for this, I'll update both packages with this and re release them. |
Hmm, a few unit test are now failing with 'OS Error: Protocol not available, errno = 92', the mqtt_client_connection_unsecure_test.dart is an example, I'll dig deeper into whats happening here. |
In what environment was the failed test run? If other than macos, then the parameters for the RawSocketOption.from... constructor are the likely cause. These values are different for Android. I see no such failures when running my app on macos. |
It fails on my main linux dev box which runs Fedora 37 as it happens, |
My Debian VM defins the TCP_keys as:
Hope this is still helping. |
Just quickly commenting out the setting of the options and seeing what happens has revealed that setting any of the options causes the problem, even if you substitute the values from Linux then you would also need values for windows and arm and ultimately RISCV. This will get to messy and will need platform specific code which I don't want to add. So, I think the best thing to do is to put a generic socket option API on the client, so the user can set up the values they want using addBool, addInt etc. and the client will apply these on connect. This way if it breaks it can easily be undone, the user is free to set any socket option they like on whatever platform they like. What do you think? |
I was concerned that these values were going to turn out to vary by platform and though not likely by version of platform.
I think your solution gives users the flexibility to use this feature if needed and avoids the quagmire that is this frequently varying code in the deep bowles of the system. Allowing package users to configure for the platforms they need is an excellent option.
… On Mar 2, 2023, at 3:43 AM, Steve Hamblett ***@***.***> wrote:
Just quickly commenting out the setting of the options and seeing what happens has revealed that setting any of the options causes the problem, even if you substitute the values from Linux then you would also need values for windows and arm and ultimately RISCV. This will get to messy and will need platform specific code which I don't want to add.
So, I think the best thing to do is to put a generic socket option API on the client, so the user can set up the values they want using addBool, addInt etc. and the client will apply these on connect. This way if it breaks it can easily be undone, the user is free to set any socket option they like on whatever platform they like.
What do you think?
—
Reply to this email directly, view it on GitHub <#245 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AK6S42SE5R5BLU3YO6V77TTW2BTTBANCNFSM4XHJZ5XQ>.
You are receiving this because you commented.
|
OK, Ill create a branch for this and add it to the client, shouldn't take too long. |
OK, I've updated the server client to accept a list of user supplied RawSocketOptions, if you could point your pubspec at the mqtt_client repo and set the branch to issue245 and look at the ' socketOptions' API it would be good to get some feeback from you before I re publish the package, thanks. |
Simple, easy and works as expected. Thank you so much.
|
1 out of approx. 50 tests of broker abruptly terminating showed an unhandled exception. Not a problem i think but wanted to let you know just in case:
|
In your use case I think this is acceptable but thanks for the research anyway. I've merged the change and re published the package at version 9.8.0, also I've raised this issue on the mqtt5_client to update it also. Closing this. |
TCP sockets allow a timeout value to be passed on connect -
This could be added as a parameter to the server client.
The text was updated successfully, but these errors were encountered: