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

new-ws-echo client anything happens #4

Closed
AndrewOzarko opened this issue Jan 24, 2025 · 16 comments
Closed

new-ws-echo client anything happens #4

AndrewOzarko opened this issue Jan 24, 2025 · 16 comments

Comments

@AndrewOzarko
Copy link

Hi. I configured dpdk and f-stack, build testes.
When I try run test_ws_client, I have next:

Checking link statusdone
Port 0 Link Up - speed 0 Mbps - full-duplex
link_elf_lookup_symbol: missing symbol hash table
link_elf_lookup_symbol: missing symbol hash table
Timecounters tick every 10.000 msec
WARNING: Adding ifaddrs to all fibs has been turned off by default. Consider tuning net.add_addr_allfibs if needed
Attempting to load tcp_bbr
tcp_bbr is now available
TCP Hpts created 1 swi interrupt threads and bound 0 to cpus
Timecounter "ff_clock" frequency 100 Hz quality 1
TCP_ratelimit: Is now initialized
f-stack-0: Addr6: ff::02
f-stack-0: Gateway6: ff::01
f-stack-0: Ethernet address: 0a:1c:05:63:12:29
f-stack-0: Successed to register dpdk interface
Set host: 3.114.215.96, port: 443, data file path: ./log_data.csv
Creating a new client...
request_uri = /ws/btcusdt@depth5@100ms, host = 3.114.215.96:443
Starting event loop...
OnCloseConnection called, fd: 1025, status_code 1006, reason:

I don't understand it wrong on code side, or maybe it happens because I have wrong in my configuration. I setup pcap file generation, but it empty and log_data.csv too.

@AndrewOzarko
Copy link
Author

test_ws_server -

OnCloseConnection called, fd: 1025, status_code 1006, reason:
Assert find_it->second > 0 failed, Call DecBufRefCount more than AddBufRefCount, line 25 in /data/flashws/include/flashws/base/buffer_manager.h
Aborted

@AndrewOzarko
Copy link
Author

I ran a simple ws server on python. Try to test: test_ws_client, but happens next:

data hash: 12542905821436587693
start to run loop

Prepare to send handshake request
GET / HTTP/1.1
Host: 172.31.35.188:58600
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: bk/9HykiDiuIouAamQp2AA==
Sec-WebSocket-Version: 13

IN custom_bio_write, fd:1025 written: -1
write return: 0, request size: 158
OnCloseConnection called, fd: 1025, status_code 1006, reason:

@AndrewOzarko
Copy link
Author

Timecounters tick every 10.000 msec
WARNING: Adding ifaddrs to all fibs has been turned off by default. Consider tuning net.add_addr_allfibs if needed
Attempting to load tcp_bbr
tcp_bbr is now available
TCP Hpts created 1 swi interrupt threads and bound 0 to cpus
Timecounter "ff_clock" frequency 100 Hz quality 1
TCP_ratelimit: Is now initialized
f-stack-0: Addr6: ff::02
f-stack-0: Gateway6: ff::01
f-stack-0: Ethernet address: 0a:1c:05:63:12:29
f-stack-0: Successed to register dpdk interface
Set host: 172.31.35.188, port: 58600, msg_size: 512, msg_cnt_per_client: 300000,data file path: ./log_data.csv
CpuTimer overhead cycles: 58 cycles, tick per ns: 2.999942
data hash: 12542905821436587693
start to run loop
Prepare to send handshake request
GET / HTTP/1.1
Host: 172.31.35.188:58600
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: lldYe+RJFdRnK0SKn0kzCw==
Sec-WebSocket-Version: 13

OnCloseConnection called, fd: 1025, status_code 1006, reason:
Cannot find socket for ptr: 0x7eeff8c00410 in read event, n_events: 2
Aborted

@renzibei
Copy link
Owner

renzibei commented Feb 1, 2025

Hi, it will help if you can provide the simplest code that can reproduce your errors. What's more, have you tried to use the non f-stack (which uses the OS net stack) build option?

@AndrewOzarko
Copy link
Author

Hi, sure. I used code from tests.

  • test_def.h

https://github.com/renzibei/flashws/blob/master/tests/new-ws-echo/test_def.h

My changes:

inline constexpr const char *SERVER_IP = "3.114.215.96";
inline constexpr int SERVER_PORT = 443;
inline constexpr bool SHOULD_VERIFY_CERT = false;
  • test_ws_client.cpp

https://github.com/renzibei/flashws/blob/master/tests/new-ws-echo/test_ws_client.cpp

My changes:

line 424

        std::string request_uri = "/ws/btcusdt@depth5@100ms";
        std::string host = std::string(SERVER_IP) + ":" + std::to_string(SERVER_PORT);

https://github.com/renzibei/flashws/blob/master/tests/new-ws-echo/config_la1_2.ini

Rename to config.ini

My changes:

For generation pcap

[pcap]
enable=1
snaplen=256
savelen=33554432
savepath=.

I try config this settings by command ifconfig
but nothing work

[port0]
addr=10.5.96.3
netmask=255.255.255.0
broadcast=10.5.111.255
gateway=10.5.96.1

Then I go to tests/build

compile your tests:

make -j6

Run

cd new_ws_echo
sudo ./test_ws_client

It execute very long, nothing happen, pcap and log_data.csv always empty.

Checking link statusdone
Port 0 Link Up - speed 0 Mbps - full-duplex
link_elf_lookup_symbol: missing symbol hash table
link_elf_lookup_symbol: missing symbol hash table
Timecounters tick every 10.000 msec
WARNING: Adding ifaddrs to all fibs has been turned off by default. Consider tuning net.add_addr_allfibs if needed
Attempting to load tcp_bbr
tcp_bbr is now available
TCP Hpts created 1 swi interrupt threads and bound 0 to cpus
Timecounter "ff_clock" frequency 100 Hz quality 1
TCP_ratelimit: Is now initialized
f-stack-0: Addr6: ff::02
f-stack-0: Gateway6: ff::01
f-stack-0: Ethernet address: 0a:1c:05:63:12:29
f-stack-0: Successed to register dpdk interface
Set host: 3.114.215.96, port: 443, data file path: ./log_data.csv
Creating a new client...
request_uri = /ws/btcusdt@depth5@100ms, host = 3.114.215.96:443
Starting event loop...
OnCloseConnection called, fd: 1025, status_code 1006, reason:

Always return 1006 code. I try to connect to ws server (test_ws_server). I try to connect to custom server that I wrote. Nothing works. code: 1006

@AndrewOzarko
Copy link
Author

I use AWS EC2 instance.
OS: Ubuntu:latest
I don't try use non f-stack option.

In my task DPDK usage is required.

@renzibei
Copy link
Owner

renzibei commented Feb 1, 2025

Here are a few points that might help clarify the problem:

  1. This client is designed to work specifically with an echo server due to its specialized pattern and requirements. It will not function properly with a general WebSocket server. Please ensure that the server side is configured as an echo server.

  2. There may be configuration errors in your config.ini file, particularly in [port0]. If I recall correctly, AWS EC2 instances typically do not use IP addresses in the 10.5.*.* range. To make it work on AWS, ensure that the NIC's IP and gateway are set according to AWS's expected network configuration.

To debug and identify the cause of the failure, you can try the following:

  • Run the examples in the f-stack repository to verify that f-stack and DPDK are configured correctly.
  • Use the non-DPDK build option to confirm that your configuration works with the examples in this repository.

@AndrewOzarko
Copy link
Author

AndrewOzarko commented Feb 2, 2025

Could implement WebSocket Client ? I think for you it not hard. I researched your repositories and saw that you solve complex tasks.
Very skilled engineer.

@renzibei
Copy link
Owner

renzibei commented Feb 2, 2025

Hello. The basic WebSocket client has already been implemented in the flashws library. The new-ws-echo is an example that demonstrates how to use this WebSocket client to build an echo client and echo server for performance testing.

This means that the WebSocketClient you mentioned is already available. If you need to use it for other purposes—such as sending messages from a WebSocket client to a WebSocket server—you can refer to the new-ws-echo example and modify the code accordingly. It should be quite simple to adapt.

In my opinion, the echo server and client example is already the easiest and most straightforward way to demonstrate how to use the WebSocket client. Any other example would just involve minor modifications to the application logic.

@AndrewOzarko
Copy link
Author

I did everything as you wrote. I modified the tests to my needs but nothing works.
I just need to connect to the websocket server and listen to it.
It's not that complicated, but it's not exactly my stack, I rarely work with it. It's not that easy to debug or understand something, since dpdk takes up the entire network interface and it becomes inaccessible to the system.

@AndrewOzarko
Copy link
Author

AndrewOzarko commented Feb 2, 2025

I call this issue:
new-ws-echo client anything happens #4

@AndrewOzarko
Copy link
Author

AndrewOzarko commented Feb 2, 2025

@renzibei My friend. Could you implement example how to connect to ws server and listen ?
Flashws lightweight and powerful library !!

@renzibei
Copy link
Owner

renzibei commented Feb 2, 2025

I understand your frustration. The coding part itself is quite simple. My suggestion would be to take the code from new-ws-echo, show it to ChatGPT, and ask it to modify the implementation based on your specific needs. ChatGPT can be a great assistant in adapting the code for your use case.

However, the more challenging part is likely the network setup rather than the coding itself. Network configurations can be tricky, and every environment is different, so I can't provide a one-size-fits-all solution. My best advice remains the same:

  1. Ensure that f-stack is working properly before diving into application-level debugging.
  2. Try running the non-f-stack version first to confirm that the issue is not related to the application level code.

Once you verify that the base setup is working, adapting the WebSocket client should be straightforward.

@AndrewOzarko
Copy link
Author

@renzibei Chatgpt has a hard time porting this code. I'm not a bad person to modify it myself. How to debug this, how to understand at what stage everything went wrong?

Ok I try.

Thank you my friend.
Could sir help me with this ?
Could we plan meeting in google calendar and discuss this issue with screen sharing ?

@AndrewOzarko
Copy link
Author

@renzibei Ok I don't want to spent a lot of time right now.
So if you open to work, please share your contact email or telegram

@AndrewOzarko
Copy link
Author

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

2 participants