Closed dandexter closed 5 months ago
Just to verify as not sure how to reproduce the problem (I might have missed what you described and assuming your input file is set to launch sim control panel automatically):
localhost
in Host : Port field and reconnect?When sim control panel is automatically launched as specified in the input file, the connection host name is set to the host name of the variable server by default. The host also can be set to a different name in the input file, for instance:
simControlPanel = trick.SimControlPanel()
simControlPanel.set_host("localhost")
trick.add_external_application(simControlPanel)
Trying to understand the reason for "there is no workaround to this problem" to help to identify the real issue here so we can make a proper update.
I have not tried this but maybe you can replicate the issue by editing your computers hosts file to add an IP address like 10.10.10.10 for your host name.
Here is why there are no workarounds that will get the sim-control panel to work on my computer:
simControlPanel = trick.SimControlPanel()
simControlPanel.set_host( "localhost" )
trick.add_external_application( simControlPanel )
Console Output:
% ./S_main_Darwin_22.exe RUN_a_side_mpr/input.py
/Users/ddexter/projects/Trick/trick/bin/trick-simcontrol wasp 51952 &
/Users/ddexter/projects/Trick/trick/bin/trick-simcontrol localhost 51952 &
This version of Mac OS X does not support the Apple EAWT. ApplicationEvent handling has been disabled (java.lang.ClassNotFoundException: com.apple.eawt.ApplicationListener)
This version of Mac OS X does not support the Apple EAWT. ApplicationEvent handling has been disabled (java.lang.ClassNotFoundException: com.apple.eawt.ApplicationListener)
^CProcess terminated by signal SIGSEGV
java.lang.NullPointerException: Cannot invoke "String.split(String)" because the return value of "trick.common.utils.VariableServerConnection.get()" is null
java.lang.NullPointerException: Cannot invoke "String.split(String)" because the return value of "trick.common.utils.VariableServerConnection.get()" is null
ddexter@wasp SIM_sine % at trick.simcontrol.SimControlApplication.getInitializationPacket(SimControlApplication.java:447)
at trick.simcontrol.SimControlApplication.initialize(SimControlApplication.java:579)
at trick.simcontrol.SimControlApplication.getInitializationPacket(SimControlApplication.java:447)
at org.jdesktop.application.Application$1.run(Application.java:186)
at trick.simcontrol.SimControlApplication.initialize(SimControlApplication.java:579)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at org.jdesktop.application.Application$1.run(Application.java:186)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Here is more information about my computer and the issue:
Really appreciate all the info. We'll look through the details and keep working on a solution
With the "python3 GIL locking solution" fix merged into master, the sim-control window now displays properly again for me. However, I still have the issue of the sim-control not working if the host name resolves to an IP address that is not assigned to a network adapter in my computer.
The good news is that I have verified that you can recreate the problem by adding a line to your /etc/hosts file with an invalid IP address for your hostname. Just edit your /etc/hosts file and add an IP address of 10.10.10.10 for your host name. For example below, replace YourHostname with the name of your computer. You may need to temporarily comment out additional entries for your hostname if they exist.
% cat /etc/hosts
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
10.10.10.10 YourHostname
With the sim-control now displaying with the latest python 3 GIL fix, I tried using the following code in my input file with mixed results.
simControlPanel = trick.SimControlPanel()
simControlPanel.set_host( "localhost" )
trick.add_external_application( simControlPanel )
Thanks for the additional info., Dan! We watched Sean did the way you suggested to recreate the problem on a Linux box and did see the the sim control coming up with delay & error. Sean was able to manually substitute the hostname with localhost and reconnect, and also he was able to start another sim control panel by providing localhost with port number without error.
We discussed one way is to add "localhost : xxx" to the "Host : Port" drop down if can't connect with message saying something like try localhost. The user might try to use sim control panel to connect a sim running on a different machine and accidentally provide a wrong hostname, so auto connecting to localhost might not what the user wants.
Btw, if you have both add external application for sim control panel and set sim control panel enabled in your input file as following, you'll see 2 sim control panels:
this sets host name as "localhost" and launches an external application as specified (in this case, it is a sim control panel) simControlPanel = trick.SimControlPanel() simControlPanel.set_host( "localhost" ) // this sets host name as "localhost" trick.add_external_application( simControlPanel )
this uses host name in var server and launches a sim control panel automatically trick.sim_control_panel_set_enabled(True)
@dandexter We've got a branch with a control panel fix that we need to do some HIL testing with before we merge. If you'd like to be a guinea pig for this, the PR is linked to this issue.
Yes, I would like to test any fix you come up with.
I still believe the underlying issue is that the host name of the local computer is being used to connect to a local simulation instead of just using localhost. It seems there are two options to fixing this issue:
We don't think that automatically trying localhost when a connection fails is necessarily the behavior we want. We like this solution, which indicates to the user that there is a problem with their network configuration. It also allows them (and with prompting) the option to manually connect to localhost by ensuring it is in the available sim list in the dropdown menu at the bottom of the sim control panel.
For more than a year this bug has prevented me from being able to work onsite because of how Trick treats hosts names and does not validate the IP address it resolves to. There is no workaround to this problem (i.e. by disabling the control panel) because I need the sim control panel to manually mode the simulations between run and freeze.
This is having a big impact on my ability to work. Please fix as soon as possible.
The issue is that Trick does not validate the IP address that a host name resolves to. I have noticed at hotels, conference centers as well as onsite the IP address assigned to a host name does not correspond to any IP address assigned to any of the network adapters in the computer. This is not a DNS problem and this is being done on purpose. The host name resolves to a public IP address but all the host network adapters have private IP addresses for the case of hotels and conference centers.
It is not clear if the issue is with the variable server, Sim Control Panel, or both.
Proposed fix:
Here is some Java code I wrote that does work that shows how to verify the host name and defaults to 'localhost' if the host not does not resolve to an IP address assigned to a network adapter..
NOTE: Updated the IP address compare to use the 'equals()' function. Dexter 3/27/2024