mcdermj / buster

Buster D-Star Reflector Client for MacOS X
Other
15 stars 7 forks source link

Set BSD socket connection timeout to 5 s #58

Closed rshuston closed 3 years ago

rshuston commented 3 years ago

Set BSD socket connection timeout to 5 s (default is 75 s) in BTRDPlusAuthenticator's -authenticate method.

rshuston commented 3 years ago

Hello Annaliese,

Here is a proposed fix for the socket timeout errors I've been experiencing on macOS Catalina. Basically what has been happening is that, when the list of addressed retrieved from auth.dstargateway.org contains "173.255.247.159" as the first IP address, the connect() call hangs for 75 s because I believe that particular address is no longer working. The 75 s is the default BSD socket timeout. The problem is that, while BTRDPlusAuthenticator's -authenticate method is waiting on this call to timeout, the rest of the app is still running, and the user is not aware that authentication has not yet happened. Hence, if the app is in this mode, every attempt to link to a reflect fails and the user does not really know why.

I originally made a hack to just skip "173.255.247.159" and that got things working. However, if another IP address starts acting up, then that one would need to be added to the "skip" list. I think the better way is to drop the timeout to something shorter. I settled on 5 seconds but there's no reason you couldn't use a different value.

Anyway, you're welcome to use this solution in whatever manner you choose.

73's Rob Huston WD8NAQ

mcdermj commented 3 years ago

Rob --

Thanks so much for your contributions here. I’ve glanced at them, but have yet to fully review them for committing. I’m not crazy about messing with the socket timeout, but I don’t have a significantly better solution right now. Yours has the advantage of working. :)

Life is pretty busy right now, but I’ll see if I can get things reviewed this weekend and maybe I can spin something to try again to get in the App Store. I’ve been having some small fights with Apple that have held that up.

Thanks again for the contributions and I apologize for not responding a little earlier.

-- Anna (NH6Z)

On Aug 1, 2020, at 10:58 AM, Rob Huston notifications@github.com wrote:

Hello Annaliese,

Here is a proposed fix for the socket timeout errors I've been experiencing on macOS Catalina. Basically what has been happening is that, when the list of addressed retrieved from auth.dstargateway.org contains "173.255.247.159" as the first IP address, the connect() call hangs for 75 s because I believe that particular address is no longer working. The 75 s is the default BSD socket timeout. The problem is that, while BTRDPlusAuthenticator's -authenticate method is waiting on this call to timeout, the rest of the app is still running, and the user is not aware that authentication has not yet happened. Hence, if the app is in this mode, every attempt to link to a reflect fails and the user does not really know why.

I originally made a hack to just skip "173.255.247.159" and that got things working. However, if another IP address starts acting up, then that one would need to be added to the "skip" list. I think the better way is to drop the timeout to something shorter. I settled on 5 seconds but there's no reason you couldn't use a different value.

Anyway, you're welcome to use this solution in whatever manner you choose.

73's Rob Huston WD8NAQ

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

mcdermj commented 3 years ago

Rob --

I skinned this cat a little bit differently than you suggested, and I let the OS deal with the connect timeout rather than dancing around setting the socket to nonblocking and using select. This is in no way portable, but Buster won't run on anything but OS X anyhow. See 33bfc8f8a77a004cb73097b6b8470f06c7034f1e for details. I also took your suggestion of the entitlements and included them as 4b5b96f1cdcb30da6cc27c73a6f1d616727ad8a4.

Thanks again for your help here, and hopefully you'll see the results in version 1.2.5 that's up for App Store review right now. Apple was hassling me about a crash bug that I couldn't reproduce and had never heard of the last time I tried to submit 1.2.4, so we'll see what happens this time.