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] I used goroutine to affect the later HTTP before the service startup #2298

Closed
luoyangwei opened this issue Dec 1, 2023 · 2 comments
Closed
Assignees

Comments

@luoyangwei
Copy link

package main

import (
	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/mvc"
)

func main() {
	app := iris.New()
	usersRouter := app.Party("/users")
	mvc.New(usersRouter).Handle(new(myController))
	// Same as:
	// usersRouter.Get("/{p:path}", func(ctx iris.Context) {
	// 	wildcardPathParameter := ctx.Params().Get("p")
	// 	ctx.JSON(response{
	// 		Message: "The path parameter is: " + wildcardPathParameter,
	// 	})
	// })

	/*
		curl --location --request GET 'http://localhost:8080/users/path_segment_1/path_segment_2'

		Expected Output:
		{
		  "message": "The wildcard is: path_segment_1/path_segment_2"
		}
	*/
  
        // Where is dispute point
	go func() {
		for {

		}
	}()

	app.Listen(":8080")
}

type myController struct{}

type response struct {
	Message string `json:"message"`
}

func (c *myController) GetByWildcard(wildcardPathParameter string) response {
	return response{
		Message: "The path parameter is: " + wildcardPathParameter,
	}
}

I write a simple project according to Wildcard in the MVC example.

If I added the code, my HTTP will be successful several times afterwards, and all the requests will not be available later, as if blocked by something. I am not sure if it is an iris problem, but I have not encountered other frameworks such as gin.

We often encounter this goroutine scene.

go func() {
	for {

	}
}()
@luoyangwei
Copy link
Author

I use the code to join Goroutine to start the service

image

Now listening on: 
> Network:  http://192.168.111.227:8080
> Local:    http://localhost:8080
Application started. Press CTRL+C to shut down.

Then run the JMater to send 1,000 requests, but stop when a non -fixed number. It did not meet the expectations, and all the requests could not be completed, only a part of the request was completed, and then the request was blocked

image

@luoyangwei
Copy link
Author

Sorry, not the framework is bug, I don't have enough understanding of Gorountine.
If gorountine does not write a function, Runtime has no chance to intervene, so it is impossible.

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