Switching to local control closes dashboard and primary client interface

I am working to put together a driver set for the UR robot and I am having some difficulties with the dashboard and primary client interfaces.

If I am in remote control when I start my code, which connects to the primary interface, dashboard interface and RTDE, everything works and I am able to read data, send commands and get the expected responses. If I then switch to local, as soon as I try to send a command on the primary or dashboard interfaces, I get an error indicating that the connection was closed by the host.

Similarly if i start the code while the controller is in local everything connects correctly. If i switch over to remote and try send the command to enable the motor, I the response that comes back says that the operation can not be performed because of a safety issue and that I have to disconnect and reconnect to the port.

Is there a way to change the behavior so that the port doesn’t get closed when I switch from local to remote and I wouldn’t need to reset the connection if I switch from local to remote?

Thanks in advance,
Eric

Due to implementation details ports have to be disconnected when switching between these modes.
The only solution is to reconnect, and send message again.