Howto: Connect Multiple PCs to the Same Machine

I discovered this back when I was making my drag/drop scripts, but am only just now deciding to drop it on the forum. Wasn’t sure it’d be useful or if anyone wanted it. For more information about the scripts, you can find that guide below.

Anyway, how the connection actually works in Luban is it simply “pings” the snapmaker every few seconds, if it gets a proper response, it’s “connected”. Pretty much EVERYTHING else, from sending gcode, changing laser power/speed, or just the live preview, is just web API commands requesting info, or sending data.

The problem with multiple connections comes down to how snapmaker decided to ‘authenticate’ the connection. I guess for safety reasons :person_shrugging:. Luban sends a connect command with a token, if it’s wrong, rejected, and you have to hit “allow” on the machine itself. Machine will force a new key after you click allow, and then Luban will save it for later connections. The second machine, however, has to request a new token, which gets saved, then the previous PCs token doesn’t work anymore.

Solution? Use the same token on both PCs! The file you need was mentioned in the above guide, but I’ll reference it here as well. The specific file in question is machine.json. On windows you can find this file by typing Windows Key + R and inputting %appdata%\snapmaker-luban followed by Enter. This will open the folder containing the file.

You can either transplant the server block of code from a connected machine, into the machine.json of the second PC, or, simply copy the file. (assuming you’re on the same version of Luban). Afterwards you should be able to connect to the same machine with both PCs. I don’t know the limit to how many connections you can do. As long as the snapmaker can respond to all PCs without getting DDoS’d with connect requests, all Luban instances will remain connected and requesting status.

3 Likes