Setup Instructions
Prerequisites
Python 3.7+ and the following packages:
pip install streamlit paho-mqtt pymodbustcp requests streamlit-webrtc opencv-python av
Running the Application
On Replit
streamlit run app.py --server.port 5000
Locally
streamlit run app.py
Opens at http://localhost:8501
Configuration File
Create .streamlit/config.toml:
[server]
headless = true
address = "0.0.0.0"
port = 5000
Complete Setup Example (with Rust Server)
Start Rust Server:
cd rust-app cargo runRun Python Bridge (in new terminal):
python attached_assets/stream_bridge_http_1757249928257.pyRun Streamlit App (in new terminal):
streamlit run app.py --server.port 5000- Access Application: Open
http://localhost:5000in browser Connect to Rust Data:
- Select HTTPprotocol
- Host:
localhost, Port:5000 - Click Connect
- View real-time Modbus data flowing through Rust server
Troubleshooting
Issue: "Video streaming dependencies not installed"
Solution:
pip install streamlit-webrtc opencv-python av
Restart the application.
Issue: "Rust server is not running"
Solution:
- Verify Rust server is running:
curl http://localhost:5000/health - Check if another application is using port 5000
- Start Rust server before running bridge script
Issue: MQTT not connecting
Solutions:
- Verify internet connection
- Check broker address and port
- Ensure firewall allows MQTT traffic
- Try default broker:
broker.emqx.io:1883
Issue: Modbus connection failed
Solutions:
- Verify Modbus server is running
- Check IP address and port
- Ensure no firewall blocking
- Verify start address and register count are valid
Issue: Video stream not loading
Solutions:
- Webcam: Allow browser camera permissions
- MJPEG/RTSP: Verify URL is accessible
- Check camera network connectivity
- Try different stream type
Issue: No messages appearing
Solutions:
- Click Refresh Messagesbutton
- Verify connection status shows "🟢 Connected"
- For MQTT: Ensure topic is subscribed
- Check that data source is sending data
Issue: Messages cleared unexpectedly
Solution:
- Protocol switching clears messages automatically
- Use Refresh Messagesto load history
- Messages are saved in
Htier_messages.pkl
System Architecture
Frontend (Streamlit)
- Multi-protocol interface
- Real-time message display
- Video streaming panel
- Configuration forms
Backend (Protocol Handlers)
- MQTTHandler: Paho MQTT library
- HTTPHandler: Requests library with polling
- ModbusHandler: PyModbusTCP library
- VideoHandler: Streamlit-WebRTC + OpenCV
Data Flow
- Protocol handlers run in background threads
- Messages saved to files (
Htier_messages.pkl)
- UI thread reads files for display
- Cross-thread communication via file system
Additional Resources
Tested Configurations
Htier_messages.pkl)MQTT:
- Broker:
broker.emqx.io:1883 - Topic:
mosttopicorsensor/#
HTTP (Rust Server):
- URL:
http://localhost:5000 - Endpoint:
/data/python_message
Modbus:
- Server:
127.0.0.1:12345(Python bridge) - Registers: 0-9 (10 registers)
Video:
- Webcam: Built-in camera
- MJPEG:
http://camera-ip/video.mjpg - RTSP:
rtsp://camera-server/stream
File Structure
project/
├── app.py # Main Streamlit application
├── attached_assets/
│ └── stream_bridge_http_*.py # Python-Rust bridge script
├── .streamlit/
│ └── config.toml # Server configuration
├── Htier_messages.pkl # Message storage
├── message_counter.txt # Message counter
└── replit.md # Project documentation
Glossary
- MQTT: Message Queuing Telemetry Transport - lightweight IoT messaging protocol
- Modbus TCP: Industrial communication protocol for PLCs and SCADA systems
- RTSP: Real-Time Streaming Protocol for video feeds
- MJPEG: Motion JPEG - HTTP-based video streaming format
- WebRTC: Web Real-Time Communication for browser-based media streaming
- PLC: Programmable Logic Controller
- SCADA: Supervisory Control and Data Acquisition
Support
For issues or questions:
- Check this documentation
- Review error messages in console
- Verify all dependencies are installed
- Ensure external services (Rust server, MQTT broker, Modbus devices) are running
- Check firewall and network settings