Websocket USER_DATA gives no response on SUBSCRIBE when using a docker container.

I am using DOCKER container to run my programs. When subscribing to book_ticker and run the code in a DOCKER container all works fine. When doing the same on user_data and run the code in a DOCKER container I get no response after calling the SUBSCRIBE method. When I run the code directly (not using DOCKER) it works.


#!/usr/bin/env python

import logging
import os
import sys

from binance.lib.utils import config_logging
from binance.um_futures import UMFutures
from binance.websocket.um_futures.websocket_client import UMFuturesWebsocketClient
from dotenv import load_dotenv

config_logging(logging, logging.DEBUG)
load_dotenv(os.getcwd() + '/.env')

def __listen_key() -> str:
    um_client = UMFutures(key=os.getenv('API_KEY'), base_url=os.getenv('BASE_URL'))
    response = um_client.new_listen_key()
    return response['listenKey']

def ws_book_ticker(func) -> UMFuturesWebsocketClient:
    client = UMFuturesWebsocketClient()
    client.book_ticker(id=13, callback=func, symbol='btcusdt')
    return client

def ws_user_account(func) -> UMFuturesWebsocketClient:
    client = UMFuturesWebsocketClient(stream_url=os.getenv('STREAM_URL'))
    client.user_data(listen_key=__listen_key(), id=1, callback=func)
    return client


DEBUG:root:url: https://testnet.binancefuture.com/fapi/v1/listenKey
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): testnet.binancefuture.com:443
DEBUG:urllib3.connectionpool:https://testnet.binancefuture.com:443 "POST /fapi/v1/listenKey HTTP/1.1" 200 None
DEBUG:root:raw response from server:{"listenKey":"JBOuEEwWxge26bWB8U8QwgtaZRrau1L8uCfop1zksm9qgK6S7sYszQPg1a98Cl2D"}
INFO:root:Connection with URL: wss://stream.binancefuture.com/ws
INFO:root:Start to connect....
INFO:root:Server connected
INFO:root:Sending message to Server: b'{"method": "SUBSCRIBE", "params": ["JBOuEEwWxge26bWB8U8QwgtaZRrau1L8uCfop1zksm9qgK6S7sYszQPg1a98Cl2D"], "id": 1}'

I expect the following message from Binance, but this is not delivered when running the code from a DOCKER container and thus I receive no updates from the USER_DATA stream.

{'id': 1, 'result': None}

Please advice.

Unfortunately, I don’t have an answer for this.
From the code and futures testnet account set up perspective, they’re all correct, so I can only assume {'id': 1, 'result': None} not been logged is related with the Docker environment.

Check all aspects of the Docker environment to ensure that all necessary configurations are properly set up. Also see if it’s not a timing issue or network latency related.