Speedygeek / ZendeskApi_v2

C# wrapper for the Zendesk API
Other
170 stars 201 forks source link

Error Socket to connect zendesk #341

Closed sergio324 closed 6 years ago

sergio324 commented 6 years ago

Hello,

I am working with ZendeskApi_v2 for several years. I haven't had any problem until yesterday. The connection with zendesk doesn't run. We were using Zendeskapi_v2 vesion 2.4.0, but we receive an error "Object reference not set to an instance of an object". Then, I have upgraded to last ZendeskApi_v2 and I have solved this problem, but the zendesk closes the connection. I work with apitoken connection and this is run well, but when we try to search user by searchByemail the zendesk close the socket connection.

I can create the object zendeskapi without error:

    private ZendeskApi InitApi()
    {
        return new ZendeskApi(
                     ConfigurationManager.AppSettings.Get("zendexUrl"),
                     ConfigurationManager.AppSettings.Get("userZendes"),
                    apiToken: ConfigurationManager.AppSettings.Get("zendexToken"),locale:"es-es");
    }

But, this call "SearchByEmail" finishes with error: _api = InitApi(); ticket.Requester = new Requester(); ticket.Requester.Email = User.Identity.Name; // +"@sodexo.com"; GroupUserResponse oUser; try { oUser = _api.Users.SearchByEmail(ticket.Requester.Email); } catch (Exception EX) { throw EX; }

This is the error:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send.Error content:
Resource String: users/search.json?query=sergio.sanchez@sodexo.com + ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream. at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) at System.Net.TlsStream.CallProcessAuthentication(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.ConnectStream.WriteHeaders(Boolean async) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetResponse() at ZendeskApi_v2.Core.RunRequest(String resource, String requestMethod, Object body, Nullable1 timeout, Dictionary2 formParameters) --- End of inner exception stack trace --- at WebHelpDesk.Controllers.ArticleSolicitudeController.SetTicket(Ticket ticket) in C:\Net\Helpdesk\HelpDesk-Des-Pasiona\WebHelpDesk\Controllers\ArticleSolicitudeController.cs:line 53 at lambda_method(Closure , ControllerBase , Object[] )

Could you help me to find the problem?

thanks for advance for your help

Regards, Sergio

sergio324 commented 6 years ago

Hello Again,

I saw the issue 339. I have solved the problem with: "2. add following code to your application this code will affect all HTTP calls. This setting is global and may need to be different for other services."

Thank a lot!!!