paullouisageneau / libdatachannel

C/C++ WebRTC network library featuring Data Channels, Media Transport, and WebSockets
https://libdatachannel.org/
Mozilla Public License 2.0
1.79k stars 361 forks source link

windows client not work. #1193

Closed hunter1303 closed 5 months ago

hunter1303 commented 5 months ago

use the python sigal server on a public machine. two clients on Ubuntu . it works. but build on windows (Mingw). the client will blocked. the server cannot received the client 's request.

paullouisageneau commented 5 months ago

I would need way more details please. Are you talking about the signaling server which doesn't receive the client request for WebSocket? What is build for Windows, the client or the server? What is the network topology? Is there a firewall? I would be useful if you could post logs showing the actual error.

hunter1303 commented 5 months ago

Yes, signaling server which doesn't receive the client request for websocket. Windows 22H2 (Os build 19045, 4412). i build all of libdatachannel. and try to use client.exe. in fact , i have no idea about network topology. it should be behind NAT. test mahine Ubuntu and windows have same network condition. may be i can catprue wireshark logs first.

hunter1303 commented 5 months ago

Ubuntu: use tcpdump, i can see package with server. Windows: Nothing. i create a dump file for checking stack. as below: image

0:000> !analyze -v !analyze -v


KEY_VALUES_STRING: 1

Key  : Analysis.CPU.mSec
Value: 1390

Key  : Analysis.Elapsed.mSec
Value: 1401

Key  : Analysis.IO.Other.Mb
Value: 66

Key  : Analysis.IO.Read.Mb
Value: 5

Key  : Analysis.IO.Write.Mb
Value: 35

Key  : Analysis.Init.CPU.mSec
Value: 2327

Key  : Analysis.Init.Elapsed.mSec
Value: 432606

Key  : Analysis.Memory.CommitPeak.Mb
Value: 123

Key  : Failure.Bucket
Value: BREAKPOINT_80000003_msys-2.0.dll!Unknown

Key  : Failure.Hash
Value: {4b70bce2-6177-cc82-dc40-a47d63a7d7f3}

Key  : Timeline.OS.Boot.DeltaSec
Value: 6098

Key  : Timeline.Process.Start.DeltaSec
Value: 222

Key  : WER.OS.Branch
Value: vb_release

Key  : WER.OS.Version
Value: 10.0.19041.1

FILE_IN_CAB: client.DMP

NTGLOBALFLAG: 400

APPLICATION_VERIFIER_FLAGS: 0

EXCEPTION_RECORD: (.exr -1) .exr -1 ExceptionAddress: 0000000000000000 ExceptionCode: 80000003 (Break instruction exception) ExceptionFlags: 00000000 NumberParameters: 0

FAULTING_THREAD: 00000a90

PROCESS_NAME: client.exe

ERROR_CODE: (NTSTATUS) 0x80000003 - {EXCEPTION} Breakpoint A breakpoint has been reached.

EXCEPTION_CODE_STR: 80000003

STACK_TEXT:
000000a33f5fe690 00000001800ad49f : 000000043584a629 0000000000000000 0000000000000018 0000000040000024 : msys_2_0!timegm+0x4aa 000000a33f5fe698 000000043584a629 : 0000000000000000 0000000000000018 0000000040000024 00007ffbb8df0000 : msys_2_0!_getreent+0x791f 000000a33f5fe6a0 000000043583c3c1 : ffffffffffffffff 00007ffb512dfc80 00007ffb512dfc78 00007ffbb8df32d9 : msys_crypto_3!CRYPTO_THREAD_run_once+0x9 000000a33f5fe6d0 000000059bbb1345 : 0000022566e1c900 00007ffb512dfc80 00007ffb512dfc78 0000022566e1c900 : msys_crypto_3!OPENSSL_init_crypto+0x81 000000a33f5fe730 00007ffb51139822 : 000000000000000e 0000000000000000 000000000000000c 0000022566e1b230 : msys_ssl_3!OPENSSL_init_ssl+0x35 000000a33f5fe760 00007ffb51117ae6 : 0000000000000202 0000022566e1b370 0000022566e1b230 0000022566e1b0c0 : libdatachannel!ZN3rtc13PacingHandler8outgoingERSt6vectorISt10shared_ptrINS_7MessageEESaIS4_EERKSt8functionIFvS4_EE+0x4ff82 000000a33f5fe7a0 00007ffb51118724 : 000000a33f5fefe0 00007ffb512af840 00007ffb512dfb00 00007ffb51116d2f : libdatachannel!ZN3rtc13PacingHandler8outgoingERSt6vectorISt10shared_ptrINS_7MessageEESaIS4_EERKSt8functionIFvS4_EE+0x2e246 000000a33f5fec60 00007ffb5116ae99 : 000087dcf3320000 000087dcf3325aea 0000000000000000 000000000000004a : libdatachannel!ZN3rtc13PacingHandler8outgoingERSt6vectorISt10shared_ptrINS_7MessageEESaIS4_EERKSt8functionIFvS4_EE+0x2ee84 000000a33f5fecc0 00007ffb510ab7e5 : 0000000000000000 0000000000000000 0000000000000000 0000000000000002 : libdatachannel!ZN3rtc13PacingHandler8outgoingERSt6vectorISt10shared_ptrINS_7MessageEESaIS4_EERKSt8functionIFvS4_EE+0x815f9 000000a33f5fefc0 00007ffb510acedc : 00007ffbcf5b5940 0000000000000000 0000000000000000 0000000000000050 : libdatachannel!ZN3rtc9WebSocketC2ENS_22WebSocketConfigurationE+0x255 000000a33f5ff340 00007ff7b295a0a8 : 0000022566bbb884 0000022566bb0150 0000000000000000 00000000000003ff : libdatachannel!ZN3rtc9WebSocketC1Ev+0x2c 000000a33f5ff500 00007ff7b29312ee : 0000000000000040 0000000000000005 00007ff7b29671d8 0000000000000000 : client+0x2a0a8 000000a33f5ff9e0 00007ff7b2931406 : 0000000000000000 0000000000000000 0000000000000000 0000000000000000 : client!__tmainCRTStartup+0x16e 000000a33f5ffa30 00007ffbcfa47344 : 0000000000000000 0000000000000000 0000000000000000 0000000000000000 : client!mainCRTStartup+0x16 000000a33f5ffa60 00007ffbcffa26b1 : 0000000000000000 0000000000000000 0000000000000000 0000000000000000 : kernel32!BaseThreadInitThunk+0x14 000000a33f5ffa90 0000000000000000 : 0000000000000000 0000000000000000 0000000000000000 0000000000000000 : ntdll!RtlUserThreadStart+0x21

STACK_COMMAND: ~0s; .ecxr ; kb

SYMBOL_NAME: msys_2_0+4aa

MODULE_NAME: msys_2_0

IMAGE_NAME: msys-2.0.dll

FAILURE_BUCKET_ID: BREAKPOINT_80000003_msys-2.0.dll!Unknown

OS_VERSION: 10.0.19041.1

BUILDLAB_STR: vb_release

OSPLATFORM_TYPE: x64

OSNAME: Windows 10

IMAGE_VERSION: 3004.9.0.0

FAILURE_ID_HASH: {4b70bce2-6177-cc82-dc40-a47d63a7d7f3}

Followup: MachineOwner

paullouisageneau commented 5 months ago

The stack trace is wrong, it doesn't make any sense. Anyway, stack traces are useless if the client doesn't encounter a crash or deadlock at a particular spot. Could you please enable verbose logging and post the client log?

hunter1303 commented 5 months ago

Hello Sir: the log output is very little.

STUN server is stun:xx.xx.xx.xx:3478 #replace with xx The local ID is bJCo 2024-05-27 18:59:10.306 DEBUG [5316] [rtc::impl::Init::doInit@113] Global initialization 2024-05-27 18:59:10.307 DEBUG [5316] [rtc::impl::Init::doInit@123] Spawning 12 threads 2024-05-27 18:59:11.828 DEBUG [5044] [rtc::impl::PollService::runLoop@164] Poll service started 2024-05-27 18:59:11.828 VERB [5044] [rtc::impl::PollService::runLoop@182] Entering poll nothing

hunter1303 commented 5 months ago

uh~ i have no idea about why rtc::WebSocket object can not constructe. i have some log in main.cpp . std::cout<< "ws construct 1\n"; auto ws = std::make_shared(); std::cout<< "ws construct 2\n"; the output of console The local ID is bTcd ws construct 1 2024-05-27 19:19:12.678 DEBUG [18340] [rtc::impl::Init::doInit@113] Global initialization 2024-05-27 19:19:12.679 DEBUG [18340] [rtc::impl::Init::doInit@123] Spawning 12 threads 2024-05-27 19:19:14.246 DEBUG [16900] [rtc::impl::PollService::runLoop@164] Poll service started 2024-05-27 19:19:14.246 VERB [16900] [rtc::impl::PollService::runLoop@182] Entering poll

nothing

paullouisageneau commented 5 months ago

The first time an rtc object is created, libdatachannel initializes the underlying libraries. Since the stack trace shows OPENSSL_init_ssl(), it looks like OpenSSL is broken and hangs. How did you build it? This also doesn't explain why the stack trace looks wonky with references to PacingHandler. I'd suggest you attempt to rebuild everything properly for Windows.

hunter1303 commented 5 months ago

build steps : $ cmake -B build -DCMAKE_BUILD_TYPE=Release (without toolchain cmake file) $ cd build $ make -j2 Ok, i will build on new PC. i will let you know the result. Thanks.

paullouisageneau commented 5 months ago

But where does OpenSSL come from? What version is it? If it is linked dynamically, do you run the executable with the right DLL?

hunter1303 commented 5 months ago

After build the client.exe. run in console. it will have error about missing dll. I copy the dll from msys/mingw direcotry to exe directory. Yes, it think have chance use the wrong dll.
the tree about exe directory as below: Folder PATH listing for volume 新加卷 Volume serial number is 921F-C0EF E:. │ client.exe │ cmake_install.cmake │ libdatachannel.dll │ libgcc_s_seh-1.dll │ libstdc++-6.dll │ libwinpthread-1.dll │ msys-2.0.dll │ msys-crypto-3.dll │ msys-ssl-3.dll │ └─CMakeFiles └─datachannel-client.dir getopt.cpp.obj main.cpp.obj parse_cl.cpp.obj about the ssl, is it msys-ssl-3.dll ? it might be part of msys

hunter1303 commented 5 months ago

Hello Sir: I had rebuild all. and it is OK. Thanks very much. image