Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket connection can't be established while in Docker container #107

Open
iTKerry opened this issue Apr 16, 2024 · 0 comments
Open

WebSocket connection can't be established while in Docker container #107

iTKerry opened this issue Apr 16, 2024 · 0 comments

Comments

@iTKerry
Copy link

iTKerry commented Apr 16, 2024

Describe the bug
I packed an ASP.NET application that consumes HuobiSocketClient into Docker image and hosted it locally using docker-compose. The same code works well outside of Docker. Also, REST API forks well from Docker. The issue is only with WSS connection.

Same approach work successfully with other exchanges from CryptoExchange.Net EXCEPT: Huobi, Kucoin, OKX

To Reproduce

Just try to establish socket connection from Docker container.

docker-compose.yml

  huobi.server:
    container_name: huobi.server
    build:
      context: .
      dockerfile: ./MyProjectName/Dockerfile
    ports:
      - "5006:5006"
    environment:
      - "ASPNETCORE_ENVIRONMENT=Production"
      - "ASPNETCORE_URLS=http://+:5006"
    networks:
      - customNetwork

Some code from program.cs

var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(5006, o => o.Protocols = HttpProtocols.Http1AndHttp2AndHttp3));

var app = builder.Build();
app.UseWebSockets();
app.Run();

Expected behavior
Connection should be established successfully.

Debug logging
Error while establishing connection:
{"Code":null,"Message":"Can't connect to the server","Data":null}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant