I have tried to add a websocket url to nginx-ws.conf
but it seems not work.
location /websocket {
include cors.conf;
include ws.conf;
proxy_pass http://node1:3014;
}
get a result below
WebSocket connection to 'ws://localhost:3001/websocket' failed: Error during WebSocket handshake: Unexpected response code: 404
Hey the issue is not with aeproject. You should check how and wether it is possible to setup local node with websockets.
Best,
Martin
Thank you @martingrigorov.chain, do you who would be able to provide support here?
i use the default aeproject config file. Here it is.
---
peers:
- aenode://pp_28uQUgsPcsy7TQwnRxhF8GMKU4ykFLKsgf4TwDwPMNaSCXwWV8@node2:3015
- aenode://pp_Dxq41rJN33j26MLqryvh7AnhuZywefWKEPBiiYu2Da2vDWLBq@node3:3015
http:
external:
port: 3013
internal:
debug_endpoints: true
port: 3113
listen_address: 0.0.0.0
websocket:
channel:
listen_address: 0.0.0.0
port: 3014
keys:
peer_password: "top secret"
dir: ./keys
chain:
persist: true
hard_forks:
"1": 0
"2": 1
"3": 2
"4": 3
mining:
autostart: true
beneficiary: "ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU"
beneficiary_reward_delay: 2
expected_mine_rate: 4000
micro_block_cycle: 1000
cuckoo:
miner:
executable: mean15-generic
extra_args: ""
edge_bits: 15
fork_management:
network_id: "ae_devnet"
i’m not sure how to connect to webcoket like mainnet.aeternal.io to get block info.
Aeproject provides a local node for the use of aeproject. If you want to connect via websockets you would probably use the js-sdk for example. In the configuration I am not sure that the websockets are exposed. Not sure how are you doing it with the aeternal.
@dincho.chain maybe can help here or any other core team member
Best,
Martin
1 Like
Yeah. I know Aeproject provide a local node.And I’m not sure if this node exposed the websocket port.(using the default config)
all config
// node.yml
---
peers:
- aenode://pp_28uQUgsPcsy7TQwnRxhF8GMKU4ykFLKsgf4TwDwPMNaSCXwWV8@node2:3015
- aenode://pp_Dxq41rJN33j26MLqryvh7AnhuZywefWKEPBiiYu2Da2vDWLBq@node3:3015
http:
external:
port: 3013
internal:
debug_endpoints: true
port: 3113
listen_address: 0.0.0.0
websocket:
channel:
listen_address: 0.0.0.0
port: 3014
keys:
peer_password: "top secret"
dir: ./keys
chain:
persist: true
hard_forks:
"1": 0
"2": 1
"3": 2
"4": 3
mining:
autostart: true
beneficiary: "ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU"
beneficiary_reward_delay: 2
expected_mine_rate: 4000
micro_block_cycle: 1000
cuckoo:
miner:
executable: mean15-generic
extra_args: ""
edge_bits: 15
fork_management:
network_id: "ae_devnet"
// nginx-default.conf
server {
listen 3001;
location / {
include cors.conf;
proxy_pass http://node1:3013/;
}
location /internal/ {
include cors.conf;
proxy_pass http://node1:3113/;
}
location /channel {
include cors.conf;
include ws.conf;
proxy_pass http://node1:3014;
}
}
// nginx-ws.conf
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "upgrade";
proxy_connect_timeout 15s;
proxy_send_timeout 2h;
proxy_read_timeout 2h;
proxy_pass_request_headers on;
node’s docker-compose
version: '3'
services:
node1:
image: 'aeternity/aeternity:${NODE_TAG}'
hostname: node1
environment:
AETERNITY_CONFIG: /home/aeternity/aeternity.yaml
command: |
bin/aeternity console -noinput -aehttp enable_debug_endpoints true
volumes:
- './docker/aeternity_node1_mean15.yaml:/home/aeternity/aeternity.yaml'
- './docker/keys/node1:/home/aeternity/node/keys'
proxy:
image: 'nginx:1.13.8'
hostname: proxy
ports:
- '3001:3001'
- '3002:3002'
- '3003:3003'
volumes:
- './docker/nginx-default.conf:/etc/nginx/conf.d/default.conf'
- './docker/nginx-cors.conf:/etc/nginx/cors.conf'
- './docker/nginx-ws.conf:/etc/nginx/ws.conf'
volumes:
node1_db: null
node1_keys: null
And I have tried the js
const webSocket = () => {
const client = new WebSocket('ws://localhost:3001/websocket');
client.onopen = () => {
console.log('open websocket');
};
client.onmessage = payload => {
console.log(payload);
};
client.onclose = () => {
console.log('close websocket');
};
};
but the result is
WebSocket connection to 'ws://localhost:3001/websocket' failed: Error during WebSocket handshake: Unexpected response code: 404
I metioned the aeternal because it can connect to websocket successfully.
Hello,
@botanicalcarebot.chain can you help here please or refer to some other core team member?
Thanks.
I believe these are 2 different things. The websocket connection to aeternal is connecting to the middleware, which is not the Aeternity node. The node only provides a websocket interface for the State Channels, thus that is not related to what you are trying to do.
Which bears the question, what are you actually trying to achieve client-side?
Hey @arvinxx
Did you succeed to do what you were trying to?