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

Singleton causing problems #3

Open
tjoskar opened this issue Oct 21, 2015 · 0 comments
Open

Singleton causing problems #3

tjoskar opened this issue Oct 21, 2015 · 0 comments

Comments

@tjoskar
Copy link

tjoskar commented Oct 21, 2015

Hi,

First of all, awesome project!

However, it seems to be a problem when the same instance of PainlessHttp is handling multiple request at the same time (thread-unsafe?).

I have the following code in a ApiController-class:

[Route("api/test")]
[HttpGet]
public async Task<IHttpActionResult> Test(string id = "0")
{
    var response = await httpSingleton.GetAsync<string>(string.Format("/echo/{0}", id)); // Replies with `id`
    return Ok(response.Body);
}

and if I make a several requests at the same time against the endpoint above (api/test/?id={id}) I can get the response all mixed up. Eg. GET api/test/1 can reply "2" (expected 1) and GET api/test/2 can reply "1" (expected 2).

Take a look at my gist to get a full example: https://gist.github.com/tjoskar/c1f65bed89d67a503728

Keep up the good work!

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

1 participant