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

[Bug]: bind: address already in use when using without reuseAddr parameter #503

Closed
3 tasks done
gohryt opened this issue Sep 14, 2023 · 2 comments
Closed
3 tasks done
Assignees
Labels
invalid This doesn't seem right

Comments

@gohryt
Copy link

gohryt commented Sep 14, 2023

Actions I've taken before I'm here

  • I've thoroughly read the documentations on this issue but still have no clue.
  • I've searched the Github Issues but didn't find any duplicate issues that have been resolved.
  • I've searched the internet for this issue but didn't find anything helpful.

What happened?

I've made a simple server

Server struct {
	Engine gnet.Engine
}
server := &server.Server{}

which implements gnet.EventHandler interface and run it with gnet

err := gnet.Run(server, "tcp://0.0.0.0:3000",
	gnet.WithMulticore(true), gnet.WithTCPKeepAlive(alive), gnet.WithTCPNoDelay(gnet.TCPNoDelay))

on the ctrl+c i'm stopping this server with

err := server.Engine.Stop(background)

All this scheme works ok, but only if not send requests to server.
When i open the 0.0.0.0:3000 page in browser it works correctly and closes gnet server correctly, but it gives "bind: address already in use" on the every next start of program

Major version of gnet

v2

Specific version of gnet

v2.3.2

Operating system

Linux

OS version

Linux 6.5.3-arch1-1 x86_64

Go version

go version go1.21.0 linux/amd64

Relevant log output

[gohryt@gohrytpc Go]$ go build && ./go
{"trace_id":"00000000000000000000000000000000","timestamp":"14-09-2023 17:46:25","level":"DEBUG","message":"boot"}
{"trace_id":"5a975d1e75b7498aa52f305845e21a78","timestamp":"14-09-2023 17:46:36","level":"DEBUG","message":"open"}
{"trace_id":"18ee031ccbae4f0290807bf83bc87a0d","timestamp":"14-09-2023 17:46:36","level":"DEBUG","message":"open"}
{"trace_id":"5a975d1e75b7498aa52f305845e21a78","timestamp":"14-09-2023 17:46:36","level":"DEBUG","message":"traffic"}
{"trace_id":"5a975d1e75b7498aa52f305845e21a78","timestamp":"14-09-2023 17:46:36","level":"DEBUG","URI":"/"}
{"trace_id":"5a975d1e75b7498aa52f305845e21a78","timestamp":"14-09-2023 17:46:36","level":"DEBUG","message":"traffic"}
{"trace_id":"5a975d1e75b7498aa52f305845e21a78","timestamp":"14-09-2023 17:46:36","level":"DEBUG","URI":"/favicon.ico"}
^C{"trace_id":"00000000000000000000000000000000","timestamp":"14-09-2023 17:46:38","level":"DEBUG","message":"shutdown"}
{"trace_id":"18ee031ccbae4f0290807bf83bc87a0d","timestamp":"14-09-2023 17:46:38","level":"DEBUG","message":"close"}
{"trace_id":"5a975d1e75b7498aa52f305845e21a78","timestamp":"14-09-2023 17:46:38","level":"DEBUG","message":"close"}
[gohryt@gohrytpc Go]$ go build && ./go
{"trace_id":"00000000000000000000000000000000","timestamp":"14-09-2023 17:46:50","level":"ERROR","error":"bind: address already in use"}
{"trace_id":"00000000000000000000000000000000","timestamp":"14-09-2023 17:46:50","level":"ERROR","error":"the internal engine is empty"}

Code snippets (optional)

No response

How to Reproduce

Steps to reproduce the behavior:

  1. start http example from https://github.com/gnet-io/gnet-examples
  2. open it's main page in browser
  3. stop http example
  4. start it again

Does this issue reproduce with the latest release?

It can reproduce with the latest release

@gohryt gohryt added the bug Something isn't working label Sep 14, 2023
@panjf2000
Copy link
Owner

This is not a bug, it's intended for TCP, see #485 (comment).

@panjf2000 panjf2000 added invalid This doesn't seem right and removed bug Something isn't working labels Sep 19, 2023
@gohryt
Copy link
Author

gohryt commented Sep 21, 2023

Maybe describe this behavior in Engine.Stop comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants