MJPEG camera not working. Getting 502: Bad Gateway

Hi,

Need help getting my mjpeg camera url from Shinobi (NVR) to work. Basically I have onvif cameras setup in Shinobi. Shinobi then re-streams these as MJPEG based on my setup. I have setup the mjpeg urls in Home Assistant like so.

camera:
  - platform: mjpeg
    name: Master Bedroom Camera
    still_image_url: http://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/jpeg/Lts5eDLTRb/1Mvvlxcj2L/s.jpg
    mjpeg_url: http://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/mjpeg/Lts5eDLTRb/1Mvvlxcj2L
    username: user
    password: password
  - platform: mjpeg
    name: Living Room Camera
    still_image_url: https://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/jpeg/Lts5eDLTRb/JB4GtuFrVg/s.jpg
    mjpeg_url: https://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/mjpeg/Lts5eDLTRb/JB4GtuFrVg
    username: user
    password: password
  - platform: mjpeg
    name: Dining Room Camera
    still_image_url: https://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/jpeg/Lts5eDLTRb/JtkUbek22J/s.jpg
    mjpeg_url: https://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/mjpeg/Lts5eDLTRb/JtkUbek22J
    username: user
    password: password

On the UI side, I used Picture Entity Card to view these.

However, it doesn’t show the stream. See screenshot below.

image

If I paste the shinobi mjpeg url directly in chrome, it works as I can see the stream with no issues.

If I inspect the section using Google Chrome inspect, I get the screenshot below.

I also get the camera url from home assistant.

http://homeassistant-server-ip:8123/api/camera_proxy_stream/camera.living_room_camera?token=c379823490098074a91981947c929d0d32c8edbd36fba3c164779bf19f22bcc5

However, if I paste this url directly to chrome, it gives out the 502: Bad Gateway error.

Here is my Home Assistant setup.

Appreciate any help to fix this.

Thanks.

hi
when you said you paste the url in chrome …and it’s working, how did you enter name and password?
i mean can’t you try add username and password in the url?and remove them from configuration file.

and you should try https://github.com/elad-bar/ha-shinobi

Hi,

Shinobi creates these urls that has the api key and then they can be used to play the stream directly. For mjpeg stream I can just copy and paste the url in chrome and it will automatically play. For HLS or other type of streams, I will need to use VLC to play them.

I also tried removing user/pass from the config but same issue,

Thanks for the link. I’ll check it out.

Hi,

For anyone who is experiencing the same issue, mine was caused by an SSL error. Apparently I had certs installed for a certain domain that I used in my Shinobi server and it was causing an issue with my configuration in Home Assistant. Changing the url from ip address to its domain solved the issue.