django: Call to remote service kills python - django

I'm writing a django app that communicates with remote service (on my VPN but not hosted locally). I can successfully communicate with the service via the django shell but when I try to call the exact same function, posting the information from a webform, the development server dies.
I would have thought the shell and the development server would behave exactly the same way. The only thing I could think of was that the shell might be more 'patient', waiting for a response?
The communication happens via protocol buffers.
Help!

The developpement server is single-threaded so if you open another connection it hangs the server.
You could try for dev purposes : http://github.com/jaylett/django_concurrent_test_server
works very well for me
Or use a real configuration, apache+wsgi for example

Related

Is there anything I should be doing to protect my security when opening a port?

I'm new to this, so I apologize if my question is a little too simplistic or I don't have the correct understanding. I can't find anything in the django guide and I'm not sure if the general port information is the same considering what i'm doing with Django.
I'm running a django runserver on '0.0.0.0:8000', which allows me to access the server remotely on another device in the same household.
Is there anything I should be doing to help protect from outside attacks as the port is open?
I believe I read that although this won't grant access to the device running the server, it can leave it vulnerable to issues. But there shouldn't be any sensitive data being transmitted as it's been used to enter data into a database.
Assuming that you have not performed any port forwarding from the internet to the device that you are running your Django server on you are safe. It will only expose the Django web service and realistically locally in your house hopefully you don't have anyone out to get you.
If you only want to be able to access your Django development server locally you can change the command to: python3 manage.py runserver 127.0.0.1:8000 no one will be able to access it unless they are coming from the same machine.

Django Development Server

Just to give you some general context of what I am doing, I am currently in the process of making a mobile app for university students to notify them when a seat becomes available in a previously full course.
For my project architecture, my web service stack is setup very similar to a LAMP stack: Linode cloud ubuntu instance for linux OS, Apache2 for my HTTP Server, MySQL for my relational database management system, and Python for my programming language.
Also, to gather the data needed for my project, I am going to web-scrape via a python script with beautiful soup and selenium (for timed delays when loading the webpages), and plan on implementing cron jobs for minutely scrapes to continuously update my database on my LAMP Stack (specifically the number of seats available in a particular course) which will then send any updates of newly open seats to the mobile app (which I will code in the future, but have not gotten to yet).
I am having a LOT of trouble installing Django on my server. Thus far, I am able to starting up the Django development server in terminal, but when I try to access the project / default Django admin interface via web browser (every time I type in my servers IP address and port 8000 it refuses to connect). I have checked my firewall settings, followed all the online recommendations of inputting my server ip etc and am currently at a roadblock.
You didn't include the command you use to run the development server but try:
python manage.py runserver 0.0.0.0:8000

python script instead of browser as client for web socket to django server

I want to have Python script instead of browser as client and the client should be able to communicate with the server by websockets.
Basically I need the server to notify a python script in some other computer that some new information has arrived. I don't want my client to poll all the time.
Is this possible? Can anybody suggest some reading for doing this?
Sure, possible. One option for Python is Autobahn (https://github.com/tavendo/AutobahnPython), which supports Python 2/3 and Twisted as well as asyncio. It allows you to write WebSocket clients.

Is it possible to run an application from a remote server on a website?

I have a website that I would like the customers to navigate to a page where it runs a program that I wrote. However, the program is on a separate server. How might I run the application from that remote server onto the server that hosts the website?
It looks like ideally I'll have my web host as GoDaddy.com and I'd like to run my application from that website.
Any thoughts?
What kind of technology are you employing to deploy the apps? ASP? PHP?
It seems that you were actually trying to "Window" the app on another server to your current site, if that's the case you can just simply link the app inside an iframe of your site.
Reference -http://www.w3schools.com/tags/tag_iframe.asp

Test a webservice on a different port locally without JSONP

I'm currently writing a webservice (with node.js) for an AngularJS frontend which is hosted with node.js
It will later be available through a proxy under domain.com/api and therefore I don't need JSONP.
For local testing purposes i have my AngularJS app running on localhost:80 and my node.js backend on localhost:3000. Naturally I'm not able to query json requests. The easies
What would be the best setup to test my homepage locally without screwing to much in my setup?
I'm currently working on windows. Linux is also an option if it is easier.
Would it be possible to write a simple proxy for express that hosts both apps in the same domain?
You can use the hosts file to set the domain.com/api to localhost. This is done in /etc/hosts in Linux, but its present somewhere in Windows too. Another thing that helps me a lot is ssh tunneling. You can, for example, tunnel remote ports (where your backend is running) to localhost with ssh -L localPort:your.server:remotePort
It's not exactly what you asked for, but the easiest might be to have the node.js app serve the AngularJS app, too. It's quite efficient, certainly efficient enough to use for development.
If it's an expressjs app, you can just add
app.use(express['static'](__dirname + "/public"));
before your other routes to have it look for static files in ./public/
If your app is served by a template or build system that you can't easily reproduce in node.js, then another option would be to run nginx, apache or haproxy on some port (80 or 5000 or ...) and have that proxy to the current backend server for the app and port 3000 (the node.js app) for the API/data requests.
You might even be able to have your server currently running on port 80 do this.
As a final idea you could also setup the node.js app to proxy to port 80 for the "app files".
Edit - I just realized that both of your apps are written in node.js. Would it be possible to set it up so you run them separately in production but together in development? Put all the real functionality in modules and then have three separate "loaders" that start the apps, one together and then a loader for each individually.