Skip to content

Sudden NullReferenceException in HandleErrorResponse when calling MessageResource.Create on production #361

@adamtal3

Description

@adamtal3

Version: reproduced on 5.4.0 and 5.5.0

Code Snippet

            try
            {
                var msg = MessageResource.Create(new PhoneNumber(phoneNumber),
                    from: new PhoneNumber(alphanumericId),
                    body: messageBody);
            }
            catch (Twilio.Exceptions.RestException ex)
            {
                    // This doesn't catch the error (it's not a RestException)
                    throw;
            }

Exception / Log

System.NullReferenceException: Object reference not set to an instance of an object.
   at Twilio.Http.WebRequestClient.HandleErrorResponse(HttpWebResponse errorResponse)
   at Twilio.Http.WebRequestClient.MakeRequest(Request request)
   at Twilio.Clients.TwilioRestClient.Request(Request request)
   at Twilio.Rest.Api.V2010.Account.MessageResource.Create(CreateMessageOptions options, ITwilioRestClient client)
   at Twilio.Rest.Api.V2010.Account.MessageResource.Create(PhoneNumber to, String pathAccountSid, PhoneNumber from, String messagingServiceSid, String body, List`1 mediaUrl, Uri statusCallback, String applicationSid, Nullable`1 maxPrice, Nullable`1 provideFeedback, Nullable`1 validityPeriod, ITwilioRestClient client)	

Steps to Reproduce

I could reproduce this error only on my production server.
Running on localhost worked as expected.
I get this error sending to a valid number that works at first but after about 5 messages it stops working (with exact same to/from/body values). Also, it fails immediately (not a timeout).
It keeps failing with this exception until I restart the application pool or the iis server.

What can cause this NullReferenceException inside HandleErrorResponse?
I couldn't get any valuable information from this exception..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions