Skip to content
This repository has been archived by the owner on Jan 22, 2023. It is now read-only.

TCP tunnel is created but connection is not establishing. #17

Open
kenilpatepy opened this issue Jul 9, 2022 · 3 comments
Open

TCP tunnel is created but connection is not establishing. #17

kenilpatepy opened this issue Jul 9, 2022 · 3 comments

Comments

@kenilpatepy
Copy link

kenilpatepy commented Jul 9, 2022

Error is like while making connection

TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

My tcp config for nginx is like

server {
server_name tcp.example.com;

location = /favicon.ico { access_log off; log_not_found off; }

location /_ws/ {
    include proxy_params;
    proxy_pass http://localhost:4500;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    send_timeout                600;
}

location / {
    include proxy_params;
    proxy_pass http://localhost:4500;
}

listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;

}

server {
server_name tcp.example.com;

location = /favicon.ico { access_log off; log_not_found off; }

location /_ws/ {
    include proxy_params;
    proxy_pass http://localhost:4500;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    send_timeout                600;
}

location / {
    include proxy_params;
    proxy_pass http://localhost:4500;
}

listen 80;

}

@azimjohn
Copy link
Owner

azimjohn commented Jul 9, 2022

Hello,
Here's the actual Nginx configuration I am using for hosting jprq TCP:

server {
    server_name tcp.jprq.io;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /_ws/ {
        include proxy_params;
        proxy_pass http://localhost:4500;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Origin "";
        
        proxy_connect_timeout       600;
        proxy_send_timeout          600;
        proxy_read_timeout          600;
        send_timeout                600;
    }
    
    location / {
        include proxy_params;
        proxy_pass http://localhost:4500;
    }

    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/jprq.io/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/jprq.io/privkey.pem;
}

Let me know if you need any further help.

@kenilpatepy
Copy link
Author

Hey Thank you for response.

I tried this configuration it gives me error like

Traceback (most recent call last):
File "C:\Users\lenovo\anaconda3\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\lenovo\anaconda3\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\lenovo\anaconda3\Scripts\jprq.exe_main
.py", line 7, in
File "C:\Users\lenovo\anaconda3\lib\site-packages\click\core.py", line 1128, in call
return self.main(*args, **kwargs)
File "C:\Users\lenovo\anaconda3\lib\site-packages\click\core.py", line 1053, in main
rv = self.invoke(ctx)
File "C:\Users\lenovo\anaconda3\lib\site-packages\click\core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\lenovo\anaconda3\lib\site-packages\click\core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\lenovo\anaconda3\lib\site-packages\click\core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "C:\Users\lenovo\anaconda3\lib\site-packages\jprq\main.py", line 63, in tcp
loop.run_until_complete(
File "C:\Users\lenovo\anaconda3\lib\asyncio\base_events.py", line 642, in run_until_complete
return future.result()
File "C:\Users\lenovo\anaconda3\lib\site-packages\jprq\tunnel_tcp.py", line 17, in open_tcp_tunnel
async with websockets.connect(ws_uri, ssl=ssl_context) as websocket:
File "C:\Users\lenovo\anaconda3\lib\site-packages\websockets\legacy\client.py", line 604, in aenter
return await self
File "C:\Users\lenovo\anaconda3\lib\site-packages\websockets\legacy\client.py", line 629, in await_impl
await protocol.handshake(
File "C:\Users\lenovo\anaconda3\lib\site-packages\websockets\legacy\client.py", line 388, in handshake
raise InvalidStatusCode(status_code)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 404

@kenilpatepy
Copy link
Author

Can you tell me cloudflare configuration because when i am trying to make connection with ip address instead of tcp.example.com it makes connection. But with host name timeout error occurs.

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

No branches or pull requests

2 participants