applest / node-applest-atem

A module to control Blackmagic Design ATEM Switchers
88 stars 30 forks source link

should reconnect instantiate a new socket on every attempt? #15

Closed TomKaltz closed 7 years ago

TomKaltz commented 7 years ago

I see that every time a connection is attempted a new udp socket is created. Should this be the case? Shouldn't the hello command just be sent out again only?

Also, I don't believe it's necessary do a manual bind since node auto-binds to a random port when you send out your first packets.

miyukki commented 7 years ago

It is True.

ghost commented 7 years ago

Yes, it's even worse: The existing UDP Sockets will not be closed when reconnecting. After a while at least on Windows an application will not be able to reconnect anymore as there are no local ports left. Do you have a quick fix for this?

TomKaltz commented 7 years ago

I modified and moved creation of UDP socket to the constructor. It only needs to be created once.

On Sun, Nov 13, 2016 at 7:40 AM, susdorf notifications@github.com wrote:

Yes, it's even worse: The existing UDP Sockets will not be closed when reconnecting. After a while at least on Windows an application will not be able to reconnect anymore as there are no local ports left. Do you have a quick fix for this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/applest/node-applest-atem/issues/15#issuecomment-260183910, or mute the thread https://github.com/notifications/unsubscribe-auth/AC0_IT9lmYI1XVkQcxLMWeWwI9mgRLhnks5q9wU2gaJpZM4Jj-VX .

ghost commented 7 years ago

Thanks, I have edited the connect method to close an existing socket before creating a new one. This has also worked for me. I did not know a reconnection is really needed or not and how ATEM handles clients internally. But good to know your approach also works fine.

miyukki commented 7 years ago

@TomKaltz @susdorf Now we pushed the new version that fixed udp initialization problem. Let's try it. If you use local_port parameter calls connect() should be move to constructor options.