Skip to content

Singleton causing problems #3

@tjoskar

Description

@tjoskar

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions