-
Notifications
You must be signed in to change notification settings - Fork 317
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
Fix: tcp-alloc example #394
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #394 +/- ##
==========================================
- Coverage 68.27% 68.15% -0.12%
==========================================
Files 43 43
Lines 2348 2352 +4
==========================================
Hits 1603 1603
- Misses 578 582 +4
Partials 167 167
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Looks good to me. I think we can safely ignore the code coverage warning: we cannot test the tcp-alloc code without the server-side implementation. |
Nice, thank you! Is there anything else I need to do related to this pull request? |
We usually wait a couple of days before merging PRs so that others can chime in. Anyway, I'd like to ask you to do a fresh rebase on the latest master, collapse your commits into a single commit (we usually try to avoid squash-merges so that authorship remains at you) and write a descriptive commit message. Look out, there are some fairly stringent rules on acceptable commit message formatting:
|
Ok, that makes sense! Will do. |
and add documentation for the tcp-alloc example
Thanks a lot, applied |
Description
Hello!
While trying out the tcp-alloc example in the turn-client examples folder, I came across an unexpected error:
panic: Failed to dial: invalid TURN server address
I documented this behavior in issue #391.
The error originated from line 151 of the example (
conn, err := allocation.DialTCP("tcp", nil, peerAddr)
). Inside the function DialTCP(), there is the following block of code:The problem stems from the fact that
a.serverAddr
is of type*net.UDPAddr
and not*net.TCPAddr
, even though we are making a TCP allocation. Upon further examination of the code, we can verify that when creating a client with the functionNewClient(config *ClientConfig)
, the TURN server address is always resolved as a UDP address, from what I understand.(client.go lines 104-134,
NewClient(config *ClientConfig)
)Then, the turnServerAddr is used as the value for the ServerAddr of the TCP allocation (see below) when the function
AllocateTCP()
is called.(file client.go, lines 353-390)
This means the
ServerAddr
is of type(*net.UDPAddr)
and not(*net.TCPAddr)
. For now, a simple solution is just to add the following code to the DialTCP function:I added this and included some documentation about the tcp-alloc in the README of the examples, as there was none.
Thank you for reading! As this is my first PR, any feedback or corrections are more than welcome.
Reference issue
#391