Python Azure: ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2427)

I have the following Flask app code:

def do_binance_trading(queue): 
    print("Going to start a socket. . .")
    socket_manager = BinanceSocketManager.getInstance() 
    socket_manager.startSocket(queue) 
    print("Socket started. . .")

@app.route("/") 
def main(): 
global process
global queue
global latestQueueData print("Ping app. . .")
if process is not None and process.is_alive():
    print("App is running. Trading process id:" + str(process.pid))    
    # Retrieve all data from the queue
    queue_data = []
    while not queue.empty():
        queue_data.append(queue.get())

    if len(queue_data) > 0 and latestQueueData != queue_data[-1]:
        latestQueueData = queue_data[-1]

    # Display all data in the queue
    return latestQueueData.replace("n", "<br>"), 200
else:
    print("Starting App. . .")
    queue = multiprocessing.Queue()
    process = multiprocessing.Process(target=do_binance_trading, args=(queue,))
    process.start()
    print("Process started. . .")
    return "Trading started", 200

if name == "main": 
    app.run()

The app is deployed to Azure Web Service. The logic is pretty much simple:

  1. Run the app. The Process starts
  2. On root refresh – get the stats from the queue for the process.

App is in general working fine, but from time to time, without any influence or logic, the process dies and I got the following Azure log trace:

2024-04-27T09:59:19.988977259Z Process Process-14:
2024-04-27T09:59:19.990693175Z Traceback (most recent call last):
2024-04-27T09:59:19.991752385Z   File "/opt/python/3.11.7/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
2024-04-27T09:59:19.991789786Z     self.run()
2024-04-27T09:59:19.991796086Z   File "/opt/python/3.11.7/lib/python3.11/multiprocessing/process.py", line 108, in run
2024-04-27T09:59:19.991800386Z     self._target(*self._args, **self._kwargs)
2024-04-27T09:59:19.991824686Z   File "/tmp/8dc60406808a4da/app.py", line 29, in do_binance_trading
2024-04-27T09:59:19.991829486Z     socket_manager.startSocket(queue)
2024-04-27T09:59:19.991832986Z   File "/tmp/8dc60406808a4da/data/binance_data_socket.py", line 73, in startSocket
2024-04-27T09:59:19.991837086Z     rel.dispatch()
2024-04-27T09:59:19.991840786Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/rel/rel.py", line 228, in dispatch
2024-04-27T09:59:19.991844886Z     registrar.dispatch()
2024-04-27T09:59:19.991849086Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/rel/registrar.py", line 126, in dispatch
2024-04-27T09:59:19.991852986Z     if not self.loop():
2024-04-27T09:59:19.991857186Z            ^^^^^^^^^^^
2024-04-27T09:59:19.991861086Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/rel/registrar.py", line 135, in loop
2024-04-27T09:59:19.991864786Z     e = self.check_events()
2024-04-27T09:59:19.991868786Z         ^^^^^^^^^^^^^^^^^^^
2024-04-27T09:59:19.991872386Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/rel/registrar.py", line 300, in check_events
2024-04-27T09:59:19.991876686Z     self.handle_error(fd)
2024-04-27T09:59:19.991880286Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/rel/registrar.py", line 185, in handle_error
2024-04-27T09:59:19.991884187Z     self.callback('read', fd)
2024-04-27T09:59:19.991888087Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/rel/registrar.py", line 179, in callback
2024-04-27T09:59:19.991898687Z     self.events[etype][fd].callback()
2024-04-27T09:59:19.991902887Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/rel/listener.py", line 127, in callback
2024-04-27T09:59:19.991907287Z     if not self.cb(*self.args) and not self.persist and self.active:
2024-04-27T09:59:19.991924987Z            ^^^^^^^^^^^^^^^^^^^
2024-04-27T09:59:19.991929087Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/websocket/_app.py", line 515, in read
2024-04-27T09:59:19.991933287Z     op_code, frame = self.sock.recv_data_frame(True)
2024-04-27T09:59:19.991936687Z                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-27T09:59:19.991940587Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/websocket/_core.py", line 461, in recv_data_frame
2024-04-27T09:59:19.991944587Z     self.pong(frame.data)
2024-04-27T09:59:19.991948187Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/websocket/_core.py", line 377, in pong
2024-04-27T09:59:19.991952087Z     self.send(payload, ABNF.OPCODE_PONG)
2024-04-27T09:59:19.991957087Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/websocket/_core.py", line 297, in send
2024-04-27T09:59:19.991960987Z     return self.send_frame(frame)
2024-04-27T09:59:19.991964487Z            ^^^^^^^^^^^^^^^^^^^^^^
2024-04-27T09:59:19.991967987Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/websocket/_core.py", line 337, in send_frame
2024-04-27T09:59:19.991971787Z     l = self._send(data)
2024-04-27T09:59:19.991975087Z         ^^^^^^^^^^^^^^^^
2024-04-27T09:59:19.991978787Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/websocket/_core.py", line 559, in _send
2024-04-27T09:59:19.992036988Z     return send(self.sock, data)
2024-04-27T09:59:19.992043088Z            ^^^^^^^^^^^^^^^^^^^^^
2024-04-27T09:59:19.992047388Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/websocket/_socket.py", line 176, in send
2024-04-27T09:59:19.992051988Z     return _send()
2024-04-27T09:59:19.992056188Z            ^^^^^^^
2024-04-27T09:59:19.992060688Z   File "/tmp/8dc60406808a4da/antenv/lib/python3.11/site-packages/websocket/_socket.py", line 153, in _send
2024-04-27T09:59:19.992065088Z     return sock.send(data)
2024-04-27T09:59:19.992069088Z            ^^^^^^^^^^^^^^^
2024-04-27T09:59:19.992073088Z   File "/opt/python/3.11.7/lib/python3.11/ssl.py", line 1243, in send
2024-04-27T09:59:19.998976055Z     return self._sslobj.write(data)
2024-04-27T09:59:19.998993255Z            ^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-27T09:59:19.998998955Z ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2427)

The process restarts and app keeps running until another exception appears. I have a feeling that i am missing some configuration in Azure. App is configured to be “Always on”

Full app configuration:
enter image description here

tryed everything i could google on this topic with no luck

New contributor

Alex Vashchenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật