Local Chromecast receiver not loading - python

I am developing a Chromecast app and currently host it locally for development purpose.
It used to work fine when I had an internal ip set as my receiver url (http://192.168.1.167:9000/receiver.html) and hosted a server on my Windows machine using
python -m http.server 9000.
Now my laptop broke and I'm working on a mac mini (also because i was going to develop an iOS sender app for my receiver anyway) so I'm trying to get the receiver hosted on the mac mini.
I'm using the same principe, internal ip of the mac-mini set as receiver url, started a server using
Python -m SimpleHTTPServer 9000.
When I try to connect to my receiver, I can't get it to load.
The Chromecast displays:
Cannot load sources (or some other english equivalent of my dutch error: 'De bronnen kunnen niet geladen worden'.)
I forwarded a port in my router to my receiver and I can reach it from outside my own network (mobile 4g), I can reach it internally, colleagues can reach it, it's just the Chromecast which somehow refuses to load the page and I can't figure out why.
The Android SDK gives me CastStatusCode.CANCELED and iOS SDK GCKErrorCodeCancelled.
I also tried to update Python to the latest version, but it didn't fix it.
The Chromecast loads other apps fine, I can ping to the Chromecast and to my devices. When the Chromecast attempts to load the app, I can briefly load the debugger but it doesn't display anything in either network or console.
I hope someone has had a similair issue or any clue on how I can get the Chromecast to connect to my server again.

Of all the things i tried the last couple of hours, I didn't think of the basic 'Have you tried rebooting it'....
Cause was firmware update...

Related

Make python Flask application accessible from the Internet with gunicorn

what I have:
I made a simple web application using Flask, which woks great on the localhost.
what I want to achieve:
I want to deploy it so it is visible in the internet.
Because Flask says that the production server should not be used for deployment I installed gunicorn.
I managed to get it working on localhost (running gunicorn server:app).
Then I tried to make it public using the -b 0.0.0.0:5000 option. it said it is running on 192.168....:5000 Now I could access the website using that ip address from my computer and also from my phone connected to the same wifi. however I was unable to connect to the website when I didn't use this wifi.
when I searched about this, I found out that the 192.168.... ip address range is reserved to the local network and cannot be accessed from anywhere else.
how do I need to run the script so it is accessible from everywhere? Do I need to modify the firewall settings? Maybe there is a better way to deploy such an app on the local machine using a different framework?
Just some additional information:
python version: 3.9
I am using a venv (and installed flask and gunicorn into it)
os: macos 11.6.1 (I could run it on an Ubuntu machine if that is easier)
This question isn't anything related with Python or Gunicorn but to networking (so maybe StackOverflow isn't the correct place to ask but other community like ServerFault)
Currently your application is already exposed on your machine in the defined port, so next step would be to forward all the traffic that comes to your router to there.
In order to do that, you will have to configure the firewall of your router to accept incoming traffic through a desired port and finally forward the traffic which comes from that port to your machine in the port 5000.
Also, in the case that you have everything already configured, it will only work if your ISP is providing you a single IPv4, what currently doesn't happen anymore but you actually are sharing that with few more people. Other option would be that you configure IPv6 incoming traffic.
As you can see, this isn't a simple task neither one that should be done without proper care, since you would be literally opening your network to possible attackers.
So, in order to simplify it at the most for you, since you already have Gunicorn, I would recommend you to use any of the resources exposed by other users as Heroku or Netlify which are free for a single application and will fulfill your expectations without requiring high amount of networking knowledge.
You would need to do the following steps:
read up and learn a lot about security for Web servers, then read some more, it is fraught with risks
find your Mac's IP address on your local network and make sure it is fixed, i.e. set as static on your Mac (under "System Preferences->Network") or reserved in your router's DHCP tables (by putting your Mac's MAC address in its allocation tables) so that it always gets the same local address on your internal network when it boots
log into your router and set up "Port Forwarding" to forward external requests (coming from the Internet) for port 5000 (or some other port) to your Mac's fixed IP address and the port 5000 where Gunicorn is serving
log into your router and find your WAN IP address, or go to http://whatsmyip.com to get the address you need to put in your browser, or your friends need to put in their browsers to see your shiny new website
as it stands, this will work until the next time your router reboots when your ISP will likely allocate it a new IP address. If you want it permanent, you need to either 1) ask your ISP for a static IP address, or 2) subscribe a DDNS service (e.g. noip.com or dyndns.com) or 3) tell your friends your new IP address every time you reboot your router
I do not know anything about gunicorn. But what I used to use when needing to deploy a flask app was pythonanywhere. They have a great and totally free hosting service. It's really fast in deploying, needs no resources from your computer and is just great. Also you would have to forward the port 5000 for your computer to enable other devices not in the same network to access your computer/flask app. That comes with security issues. However, you do not need any of that when using pythonanywhere.
There are also other great hosting services like that one. It's just the only one I know and used yet but you'll find others for sure if you don't like that one.

VirtualBox Flask Server / Ubuntu 16.04 32-bit / Server stops responding periodically

I'm not sure where to post this since I don't really know if this is an issue with Flask, VirtualBox (6.0) or Ubuntu (16.04 LTS).
Intro
My company installs Ubuntu VMs for our clients that run a local Flask web server on their system. I know Flask is not meant to be used for production, but each individual server handles about 15 users max (and often just 1 or 2) and usually only one or two users at a time. So far it's been working well for dozens of clients over several months.
Problem
We have a couple of clients where the application becomes inaccessible in users' browsers after a certain period of time. I can SSH to the VM and see that the Flask service still seems to be running without issue. But the users are not able to connect to the IP address and port of the VM via their browser like they could before (eg. http://<vm_ip>:<port_number>).
Restarting the service doesn't resolve the issue, but restarting the entire VM does resolve it.
The flask application runs as a service, but all the service is doing is triggering a bash script that runs python run.py.
The VM network adapter is set to "NAT" and it serves the Flask app on the same IP address as the host machine. When the app becomes inaccessible, I'm not able to connect to the application on the host machine using either http://<vm_ip>:<port_number> or http://localhost:<port_number>. We have this same configuration on many client systems and it works without issue for all other clients.
Nothing should change in the application configuration when the VM restarts. All networking and port settings are static. So something is clearly getting hung up. Since the application output doesn't show anything off and the Flask service seems to restart fine internally, I'm guessing the issue is with Ubuntu or VirtualBox (or something on the client machine/network).
Question
I'm wondering what would cause a Flask server that runs very reliably in most cases, to periodically stop responding after a certain amount of time, even though the VM is accessible and Flask appears to be running fine internally.
I apologize for lack of details and logs - our access to the client machine is limited. I will try to get my hands on these.

How to browse IIS deployed flask rest api on windows server 2012 r2 from Internet

I deployed my flask rest api on IIS 8 to windows server 2012 r2. I followed this article. (https://medium.com/#bilalbayasut/deploying-python-web-app-flask-in-windows-server-iis-using-fastcgi-6c1873ae0ad8) I can browse the rest api on the local server but I can not browse the api from other computers on public internet. I can ping the public IP of the server without problem. There is no firewall rule that blocks the server. Would you please help me?
PS. I am trying to browse by the IP, 185.201.212.219. Is it related to this?
edit1: I will try this which is from flask documentation.
Externally Visible Server
If you run the server you will notice that the server is only accessible from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer.
If you have the debugger disabled or trust the users on your network, you can make the server publicly available simply by adding --host=0.0.0.0 to the command line:
flask run --host=0.0.0.0
This tells your operating system to listen on all public IPs.
edit2: Adding host parameter didn't work.
Is there any ideas?
Thanks in advance.
All ports except 80 was open. When I set port=80, all my troubles seem so far away :)

Google app engine endpoints api not working in localhost

I am trying to start a python app-engine project on localhost. I am in a Windows 8.1 machine (Python version 2.7). The project code is copied from here link. The server seems to start but the page wouldn't properly load due to some problem. Probably it can't reach the api server.
Here is a shot from firebug showing the failed request
What seems off to me is that in command prompt (I started the dev server from there) the API server is started at some random port other than the module port. But the webpage is trying to access the http://127.0.0.1:8000/_ah/api/static/proxy.html... page at the module port. I tried accessing it at the API server port it does open some page there. (I mean I tried opening http://127.0.0.1:1532/_ah/api/static/proxy.html... seperately) It returns some json I don't understand...
{app_id: dev~udatut-bs, rtok: '0'}
Command prompt log:
Here's the difference between the outputs in localhost and *.appspot.com
Should get this:
But stuck here:(check buttons are not loaded)
I finally found a solution here.
Steps for windows:
Goto your google appengine installation folder and then ./google/appengine/toots. (C:\Program Files (x86)\Google\google_appengine\google\appengine\tools) if you followed default installation instructions.
Open the file appengine_rpc.py and look for the line (towards the end of the file)
opener.add_handler(fancy_urllib.FancyProxyHandler())
and comment it out like
# opener.add_handler(fancy_urllib.FancyProxyHandler())
Close the app and restart it again.

Running Node or Python app from a Linux Azure VM

I can't seem to figure this out. I created a new Ubuntu VM on Azure and I can SSH into it. I installed Node (which I've done many times) and I tried to run the test app from nodejs.org:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
However, when I go to the IP (which is the same one I SSHed into the box from) + :1337 it just never loads. I tried :80 too, but still no luck. I also tried running python -m SimpleHTTPServer on :8000 and I still can't view the site. I must be missing something.
Just so you know, I'm just trying to setup a simple dev box with a bunch of projects on it. I want to be able to work on my projects anywhere. Some are 100% front-end JS projects so SimpleHTTPServer would be fine. Some are Node projects too. In either case, I just want to be able to hit some port and see what I'm working on.
Oh also I opened up the Azure firewall to the VM, redirecting traffic from port 80 to port 1337 (https://www.evernote.com/shard/s5/sh/3aef8e76-04f6-48cb-84f9-32462bc425a7/f0cd749773a9d09cee66d00fe3e707c0)
You are listening loopback ip address. Try .listen(1337, '0.0.0.0'); to listen on all network interfaces
urgh azure. i cannot get port 80 open. is it the machine iptables?? some azure magical thing.
i know it cant be that hard.
unlike your view i do not see 'NONE' for load balancer. i see '--'/ whatever that means.

Categories

Resources