waveform80 / pistreaming

A little demo of streaming the Pi's camera to web browsers
BSD 3-Clause "New" or "Revised" License
765 stars 205 forks source link

Cannot open video stream on the web #22

Closed adrianobarroso closed 7 years ago

adrianobarroso commented 7 years ago

Hi all,

Made the setup and everything is working fine in my local wireless connection.

I have opened the port 8082 on port forwarding in my router, I can reach the server remotely and see its response. However, I dont get the video streaming, I dont know what should I do to get working on web. Its maybe related to router port forwarding or something like that? Could someone give any clue?

Its even strange because I can see the request on my Pi log, and it shows any error.

Thanks in advance.

WayneKeenan commented 7 years ago

have a look at the startup messages...

Initializing websockets server on port 8084
Initializing HTTP server on port 8082
adrianobarroso commented 7 years ago

Ok, should I enable the port 8084 as well?

I did that and still is not showing the image, only the "loading...".

Could you please be more specific?

WayneKeenan commented 7 years ago

more specific, but you asked for "any clue" :)

Which os/browser (& versions) are you using for the client when on your wifi/lan and when accessing via the internet ?

adrianobarroso commented 7 years ago

Sorry is because I'm kinda of newbie in this world. :)

In my Pi is Raspbian:

~ $ cat /etc/os-release
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"

Browsers: In my local connection it works perfectly. However, when I try to watch the streaming from the web outside my local connection it doesnt work, it shows the site and the loading without showing the video.

I enabled port forwarding in my router for ports 8082 and 8084, but it dont work.

I think it might be something related to port forwarding with my router.

WayneKeenan commented 7 years ago

Can you confirm you use exactly the same setup (OS & browser combination) when on your Wifi and also when trying to access from outside your home network via the internet?

Your router rules should allow TCP (as opposed to UDP) traffic in both directions.

Open your browsers JavaScript console and paste here any errors you see.

adrianobarroso commented 7 years ago

MacOS X El Capitan Browser Chrome

Both when on my Wifi and outside.

My router is configured allowing TCP for both directions.

And on my browser I dont see any console error. :/

WayneKeenan commented 7 years ago

ok, it's not your router.

The server is serving up a local ip to your client connecting via the internet... I have a fix.

WayneKeenan commented 7 years ago

Have a look at this.

Basically change the part of the line (51) in server.py that looks like this:

self.request.getsockname()[0]

with this:

"' + window.location.hostname +'"

adrianobarroso commented 7 years ago

Hey @WayneKeenan , I will try right now, but makes total sense. Looking the network requests on chrome browser it shows the Pi local IP address not my network address.

adrianobarroso commented 7 years ago

Its working!!!!! Thanks @WayneKeenan for the quick and awesome help!!!

Would you merge this fix into master?

WayneKeenan commented 7 years ago

I'm not able todo that, ping @waveform80

waveform80 commented 7 years ago

Ahh, this actually came up in #15 but there I just suggested hard-coding the link to the websocket. You can probably tell I'm not a regular web-developer as I wasn't aware window.location was no longer a simple string! That's a very nice trick and I'll certainly add it in :)