What happens during AWS Elastic Beanstalk 504 Gateway Timeout - python

I have a Django server running in Elastic Beanstalk and I am not sure if the process continues to run in the server or the process gets killed. Does anyone have any insight on this? There is no application logic to stop the request in case of a disconnection. Would Elastic Beanstalk kill off the process along with the client connection or will the process continue to run regardless of the timeout?

A 504 Gateway Timeout means the client trying to access the server doesn't get a response in a certain amount of time. According to the AWS documentation:
Description: Indicates that the load balancer closed a connection because a request did not complete within the idle timeout period.
Which means, the 504 response you get in your browser (or other client) when trying to access your Django app is generated by the Elastic Load Balancer that's in front of your actual server after closing the connection. Since your ELB is an external networking tool and has no actual control over your server, it cannot control your code and which processes are running or not. Meaning, the process will keep running until it has to return an HTTP response and it fails because of the closed connection.

Related

Spring-Boot REST endpoint, increase number of retries/connection from a single host Tomcat will accepts

I'm load testing a Spring Boot API, a POC to show the team it will handle high throughput. I'm making the requests with a Python script that uses a multiprocessing pool. When I start sending more than like 10,000 records I get an error that "Max retries exceeded" which I've determined means the endpoint is refusing the connection from the client, because it's making too many connections.
Is there a Tomcat setting to allow more requests from a client (temporarily) for something like load testing? I tried setting "server.tomcat.max-threads" in the applicatin.properties file, but that doesn't seem to help.

OPC UA zombie connection

I recently started working with Yaskawa's OPC UA Server provided on its robot's controller.
I'm connecting to the server via Python's OPCUA library. Everything works well, but when my code crashes or when I will close terminal without disconnecting from the server I cannot connect to it once again.
I receive an error from library, saying:
The server has reached its maximum number of sessions.
And the only way to solve this is to restart the controller by turning it off and on again.
Documentation of the server is saying that max number of sessions is 2.
Is there a way to clear the connection to the server without restarting the machine?
The server keeps track of the client session and doesn't know that your client crashed.
But the client can define a short enough SessionTimeout, after which the server can remove the crashed session.
The server may have some custom configuration where you can define the maximum number of sessions that it supports. 2 sessions is very limited, but if the hardware is very limited maybe that is the best you can get. See the product documentation about that.

find out why my web server becomes unavailable

I have a python web server (django)
It talks to other services such as elasticsearch
I notice when elasticsearch goes down, the web server soon (after a few minutes) stops responding to client requests.
I use https://github.com/elastic/elasticsearch-py and it implements timeout and don't think it's blocking.
My hunch is that requests piles up during the timeout period and server becomes unavailable but it's a just guess.
What's the reason for the server not being able to handle requests in such a scenario and how do I fix it?
I have nginx - uwsgi - django on unix (amazon ecs) setup if that makes difference

Bluemix Flask API Call Timeout

I have an API written with python flask running on Bluemix. Whenever I send it a request and the API takes more than 120 seconds to respond it times out. It does not return anything and it returns the following error: 500 Error: Failed to establish a backside connection.
I need it to be able to process longer requests as well. Is there any way to extend the timeout value or is there a workaround for this issue?
All Bluemix traffic goes through the IBM WebSphere® DataPower® SOA Appliances, which provide reverse proxy, SSL termination, and load balancing functions. For security reasons DataPower closes inactive connections after 2 minutes.
This is not configurable (as it affects all Bluemix users), so the only solution for your scenario is to change your program to make sure the connection is not idle for more than 2 minutes.

Send websocket request from Django

Here is my deal:
I have a websocket pubsub server written in python with autobahn websocket (based on twisted).
I have simple website that is connected to the server and subscribed to one channel
Next to this I have simple Django project with one app
And at last I have opened terminal with curl get request that hits my Django app
After request form curl hits my django app and my view I need to send message to the server to the channel that my website is subscribed on. Basically I need websocket client that can send message to specific channel and can be run in django view (no infinite blocking loop).
I've tried to figure out this over 4 days. I've wrote to writ autobahn pubsub client with twisted.reacotr, but I can send the message only once (after I stop reactor to finish django request I cannot start it again, because it's not restartable).
I've olso tried djagno-socketio, but there is but, so I cannot see clients when I try to send the message from django view.
ws4py doesn't support channels
Thanks for any advice. Great would be an example.
You should be able to run Django and Autobahn within 1 server:
Here is an example that shows how to use Flask/WSGI with Autobahn. And Django can run in a WSGI container as well.
Also it should be possible to run an Autobahn-based WebSocket client from a Django/WSGI/Twisted based server using above method as well.
The point is: Twisted can act as a WSGI container and will then run the WSGI Web app (which can be blocking) on a background pool of worker threads. This will allow you to use the asynch features of Twisted, and e.g. run Autobahn - either client or server. So you might also rethink the overall architecture: why run the Autobahn server as a different process at all?

Categories