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

TCP always times out #8

Open
jmeaster30 opened this issue Jan 16, 2024 · 3 comments
Open

TCP always times out #8

jmeaster30 opened this issue Jan 16, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@jmeaster30
Copy link
Owner

It seems to finish resolving exactly when the connection times out

@jmeaster30 jmeaster30 added the bug Something isn't working label Jul 6, 2024
This was referenced Nov 27, 2024
@jmeaster30 jmeaster30 added this to the Home Network Complete milestone Dec 12, 2024
@jmeaster30
Copy link
Owner Author

jmeaster30 commented Dec 12, 2024

I was testing this last night a bit and the behavior is strange.

Steps:

  1. Start simpledns server with 1 thread, tcp on, udp off, some other listening port if needed, and debug logging on (base off Split the cache table from the record table #29 for the better feature flag thing)
  2. Make dig request like dig @0.0.0.0 -p 12345 google.com +tcp

Notice:

  1. You get a log saying a request was made
  2. It stops at the remote lookup and hangs It was hanging before the remote lookup call
  3. Once the dig command times out, the remote lookup request goes through, we get the response properly, and seemingly we return everything properly
  4. All of the logs after the hang have the same timestamp showing that they were just not flushed to stdout when they ran This thought was based off 2 which was wrong
  5. Failed shutdown error could be because we try to shut down both ends of the tcp connection but the client already disconnected
  6. Dig retries immediately but there is a 10 second gap in logs between the previous attempt and the retried attempt
  7. Remote lookup is always in udp. Not sure if mixing those is an issue but with the log timestamps showing the remote lookup happening in less than a second I am more inclined to think that isnt the issue.

@jmeaster30
Copy link
Owner Author

I have considered switching all networking/async stuff to use tokio but I would rather figure this out before switching anyway

@jmeaster30
Copy link
Owner Author

I definitely read the logs wrong LOL but I fixed this with #29

What was wrong:

  1. used stream.read_to_end but the TCP stream doesn't have an EOF indicator after each packet so this just blocked the thread
  2. not writing the response packet's size to the stream prior to sending the response packet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant