Failed Signup: Request to Webtask got ESOCKETTIMEDOUT

I’ve seen a couple similar questions, but they all seem to relate to log in, rather than user creation.

Here is my getUser script:

async function getByEmail(email, callback) {
  console.log('getByEmail', email);
  const fetch = require('node-fetch');
  const url = `${configuration.ApiUrl}/api/v1/User?email=${email}&accessToken=${configuration.Auth0AccessToken}`;
  console.log('fetching...');
  try {
  const response = await fetch(url);
  console.log('status:', response.status);
  if (response.status === 404) {
    callback(null);
  }
  else if (response.status === 200) {
    const profile = await response.json();
    callback(null, profile);
  }
  else {
    callback(new Error());
  }
  }
  catch (e) {
    console.log('in error', e);
  }
}

And here is the output from the Realtime Webtask Logs:

9:07:34 AM: new webtask request
9:07:34 AM: getByEmail mgrande+fifteen@example.com
9:07:34 AM: fetching...
9:07:54 AM: status: 404
9:07:54 AM: finished webtask request

It seems to always complete in exactly 20 seconds, which I assume is a timeout somewhere on your side.

Now here is the odd part… If I use the “Try It” function within the Auth0 Management page, it completes properly almost immediately. Any suggestions would be appreciated.

I don’t know if this is related, but I’m using the NuGet package Auth0.ManagementApi v7.0.1 to connect to the API.

Hi @mgrande,

The URL you are using does not match any endpoint I am familiar with. It looks like you are getting a 404 not found error.

Maybe try this:

Hope this helps,
Dan

Hi Dan, the URL provided in the code is hitting my (existing) endpoint. We’re using it to transfer users from our system to Auth0.

Sorry for the confusion!

Edit: To clarify, that endpoint returning a 404 means that no user with that email address has been found within our system (which is a good thing in this case, as it’s a new user attempting to create an account).

@mgrande,

Can you show us call to the auth0 api?

Sure, here’s an excerpt of my API calls.

I can assure you the domain, connection, etc variables are all correctly set up, as I can modify users, request a password reset, etc.

public void CreateUser(string email, UserModel user, string[] roles)
{
    var ucr = new UserCreateRequest
    {
        Connection = _auth0Connection,
        UserId = user.Id.ToString(),
        VerifyEmail = false,
        Email = email,
        EmailVerified = false,
        Blocked = user.Disabled,
        FirstName = user.Person.GivenName,
        LastName = user.Person.FamilyName,
        Password = Guid.NewGuid().ToString(),
        AppMetadata = new Dictionary<string, string[]> {{"roles", roles}}
    };

    using (var managementApi = GetManagementApi())
    {
        AsyncContext.Run(() => managementApi.Users.CreateAsync(ucr));
    }
}

private ManagementApiClient GetManagementApi()
{
    var authToken = GetManagementAuthToken();
    return new ManagementApiClient(authToken, new Uri($"https://{_auth0Domain}/api/v2/"));
}

private string GetManagementAuthToken()
{
    var clientId = _auth0ManagementClientId;
    var clientSecret = _auth0ManagementSecret;
    var audience = $"https://{_auth0Domain}/api/v2/";

    var client = new RestClient($"https://{_auth0Domain}/oauth/token");
    var request = new RestRequest(Method.POST);
    request.AddHeader("content-type", "application/x-www-form-urlencoded");
    request.AddParameter("application/x-www-form-urlencoded", $"grant_type=client_credentials&client_id={clientId}&client_secret={clientSecret}&audience={audience}", ParameterType.RequestBody);
    IRestResponse response = client.Execute(request);
    JsonObject json = SimpleJson.SimpleJson.DeserializeObject<JsonObject>(response.Content);
    return json["access_token"].ToString();
}

I should also say, this code was working as of last week, so I’m unsure what could’ve changed.

And you are getting a success or error here?

I’m getting an error. It’s throwing a 500 server error with no message here.

When I check the logs within the management page, I see the error listed above.

Can you dm me the name of your tenant so I can take a look?

Thanks,
Dan

I think you may be missing a callback after this.

You’re correct that there’s no callback there, but when I was looking yesterday, that wasn’t being hit, so I’m not sure that was the issue…

Yes, still not working :confused: I’m gonna triple check all my tokens/keys/issuers are correct… but that would return a different error, wouldn’t it?

Hmm yes, I don’t think you would see a timeout if it was an invalid token, but it would depend how your API was set up to handle it.

It seems like this error is usually happening when the webtask is either waiting for a response for long enough to time out or when there is no callback. Are you sure your API is giving a response? Can you try some console logging to see what is happening before you report the 404

Not much happens beforehand… I create a fetch request to hit my API, and then analyze the response.

When using it from the “Try It” button, I get a response almost right away (within a second or so).

When using it in a real, deployed, app, it takes exactly 20 seconds to respond, but I get the timeout error message regardless.

Are you aware of any issues using the async/await keyboards? fetch? Anything like that?

Hi Dan, I’m unfortunately still seeing this.

Is there anything else you can suggest? It works fine on my local machine, and the deployment (seems to) have everything set up correctly… But the GetUser returns a timeout no matter what.

My API is returning data near-instantly from the “try it” page, or from a browser, or via Postman; It’s only when it’s called from Auth0’s actual login flow that causes problems, and when I check my logs, my API (seems to) return successfully.

(For what it’s worth, I tried replacing the async/await with a promise chain, but to no avail)

Let me know if you have any suggestions, thanks.

Hi @mgrande,

Did you ever send me your tenant name in a DM? Can I take a look?

I thought I had, but I didn’t see anything, so sorry! I’ve re-sent it now.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.