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)

  1. Start Rust Server:

    cd rust-app
    cargo run
  2. Run Python Bridge (in new terminal):

    python attached_assets/stream_bridge_http_1757249928257.py
  3. Run Streamlit App (in new terminal):

    streamlit run app.py --server.port 5000
  4. Access Application: Openhttp://localhost:5000 in browser
  5. 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:

  1. Verify Rust server is running: curl http://localhost:5000/health
  2. Check if another application is using port 5000
  3. 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:

  1. Click Refresh Messagesbutton
  2. Verify connection status shows "🟢 Connected"
  3. For MQTT: Ensure topic is subscribed
  4. 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

MQTT:

  • Broker: broker.emqx.io:1883
  • Topic: mosttopic or sensor/#

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:

      1. Check this documentation
      2. Review error messages in console
      3. Verify all dependencies are installed
      4. Ensure external services (Rust server, MQTT broker, Modbus devices) are running
      5. Check firewall and network settings