This guide provides step-by-step instructions for troubleshooting connection issues with the CODESYS API HTTP server.
-
Verify CODESYS Path
python debug_codesys_path.pyThis confirms that the CODESYS executable can be found at the configured path.
-
Test HTTP Server Only (No CODESYS)
run_test_server.batThis starts a simplified HTTP server that responds to API requests without connecting to CODESYS. Test with:
python example_client.pyin another window. -
Run Full Server
run_server.batThis starts the complete HTTP server that connects to CODESYS. Test with:
python example_client.pyin another window.
If you're experiencing connection issues, follow these steps:
Verify that CODESYS is correctly installed and that the path in HTTP_SERVER.py matches your installation:
CODESYS_PATH = r"C:\Program Files\CODESYS 3.5.21.0\CODESYS\Common\CODESYS.exe"You can modify this path if your installation is different.
Ensure that:
- The script has permission to execute CODESYS
- The temporary directories can be created and written to
- No firewalls are blocking HTTP connections
Run the test server to isolate HTTP issues from CODESYS issues:
run_test_server.bat
In another command prompt, run:
python example_client.py
If this works, the issue is with CODESYS integration, not HTTP functionality.
Enable detailed logging in HTTP_SERVER.py:
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
filename='codesys_api_server.log'
)Then check the log file after running the server.
Cause: The server is terminating connections unexpectedly. Solutions:
- Increase timeout values in
HTTP_SERVER.py - Check if CODESYS is running correctly
- Verify script execution permissions
Cause: Unable to start CODESYS process. Solutions:
- Check the CODESYS path
- Run CODESYS manually to verify it works
- Check for permissions issues
Cause: Scripts take too long to execute. Solution: Increase the timeout value:
# In HTTP_SERVER.py
SCRIPT_EXECUTION_TIMEOUT = 120 # secondsFor more detailed debugging:
debug.bat
This will present a menu with additional debugging options:
- Check CODESYS path
- Run HTTP server with debugging
- Run test server
- Full system test
If you continue to experience issues after following these steps, please:
- Collect all log files
- Note the exact error messages
- Document which debugging steps you've tried
- Create a detailed issue in the GitHub repository