raduvarga / Focusrite-Midi-Control

APP DOWNLOAD LINK (Mac OSX)
https://github.com/vargaradu/Focusrite-Midi-Control/raw/master/Focusrite%20Midi%20Control.zip
35 stars 4 forks source link

Random server port #3

Open daveyijzermans opened 5 years ago

daveyijzermans commented 5 years ago

Hi! Thanks for your work in sniffing the Focusrite server protocol! I've used it to create my own implementation in Node.js. However, I try to connect with my client to a different computer on the network.

Until now this has worked, but suddenly the port to the control server has changed! It first was 49935, now on one computer it's 49930 and on another computer it's become 49943.

In your source code the port is hardcoded as 49152 (AppDelegate.swift, line 16) but this has never been the case for me.

I'm using the Focusrite Control Server on Windows though, might that be a cause of the issue? Do you have an idea how I can search for the right port each time or why even the port is changing?

Thanks!

raduvarga commented 5 years ago

Hi! Good question! I experienced a similar issue, my case was that at some point I had another server installed which took port 49152, and noticed that FocusriteControlServer would start on 49153. This was the case only sometimes, depending on which of the two servers would start first. My guess would be that for Mac, the default port is 49152, then if not available they increment until they find something available.

I have 2 solutions in mind:

  1. Run a terminal command in the code which gets the port of "FocusriteControlServer"
  2. Incrementally try ports until you get a valid response. Considering the jumps you've described (49930-49943), this might be inefficient and take too long.

Right now I don't have time to code them into the Swift app, let me know if you have a working solution.

daveyijzermans commented 5 years ago

Thank for your response! I thought about this approach as well, but thinking it would be rather slow. So I downloaded the iOS app, configured Wireshark to sniff my iPhone traffic. Turns out the iPhone sends a UDP broadcast message. Focusrite Control Servers on the network listen to this and is they receive a message they send back a response with the correct port!

See this gist for a Node.js implementation. I think you can rewrite this to C/Swift if you want to include it in your application. Sorry I don't know C(++)/Swift!

https://gist.github.com/daveyijzermans/f0354858b3eb765e19361ab85a6bc55b

Hope that helps. Sorry I answered my own question the day after. 😅

Kind regards,

Davey

raduvarga commented 5 years ago

Great find, thanks for sharing this gist!

xnaron commented 5 years ago

Thank for your response! I thought about this approach as well, but thinking it would be rather slow. So I downloaded the iOS app, configured Wireshark to sniff my iPhone traffic. Turns out the iPhone sends a UDP broadcast message. Focusrite Control Servers on the network listen to this and is they receive a message they send back a response with the correct port!

See this gist for a Node.js implementation. I think you can rewrite this to C/Swift if you want to include it in your application. Sorry I don't know C(++)/Swift!

https://gist.github.com/daveyijzermans/f0354858b3eb765e19361ab85a6bc55b

Hope that helps. Sorry I answered my own question the day after. 😅

Kind regards,

Davey

Hi Davey, Any chance you can share your node.js code? I'd like to experiment with it as I am trying to interface to a hardware volume knob I built.
thanks, Brendin

daveyijzermans commented 5 years ago

When you run the gist it should spit out the server ip and port of any Focusrite Control Server running and you can create a standard UDP socket to it and interact with the server as figured out by this repo's creator. It's fun to try to decode it yourself. :)

If you're looking for an example, you can take a look at my project. Although it is part of something else I think you can extract the necessary bits from it.

xnaron commented 5 years ago

When you run the gist it should spit out the server ip and port of any Focusrite Control Server running and you can create a standard UDP socket to it and interact with the server as figured out by this repo's creator. It's fun to try to decode it yourself. :)

If you're looking for an example, you can take a look at my project. Although it is part of something else I think you can extract the necessary bits from it.

Thanks. I built the UDP discovery based off of your code for my ESP8266 Arduino project.

raduvarga commented 3 years ago

@daveyijzermans Massive thanks for figuring out the UDP trick, extremely helpful! I've coded a completely new version that's much more stable, if you're curious you can check it here: https://www.raduvarga.com/software/focusrite-midi-control