WCF error time - Await Jquery Post

Asked

Viewed 41 times

2

I have this method, which until then works well:

$('#modelEditar').submit(function (e) {


$.post($(this).attr('EnvioLote'), $(this).serialize(), function (json) {
        if (json.sucesso == false) {
            $("#mensagemalerta").html(json.resultado);
            $("#alerta").show();
            $("#alerta").fadeTo(3000, 500).slideUp(500, function () {
                $("#alerta").slideUp(500);
            });
        }
        else {
            alert('Lote Enviado com Sucesso.');
            window.location.href = "/NFSe/EnvioLote/";
        }
    }, 'json');

    return false;
});

What happens is that when it takes too long, because it is signing a large file, it returns an error 500. I would like him to wait for the return after sending to the webservice, because first sign, and send, and if successful or not, it returns. To then show the result.

He goes to this signing line:

 var assinar = await client.AssinarXmlRAsync(empresa.Caminho + "\\NFSe-LOTE" + model.IdLote.ToString().PadLeft(15, '0') + ".xml", "Rps", "InfDeclaracaoPrestacaoServico", empresa.Serial, Numero.ToString(), empresa.Pin);

And as the return delay, it shows the error. I need it to wait for the return.

EDIT How I’m using WCF now he’s returning the following error, which was what I imagined, the time:

Timeoutexception: The request Channel timed out attempting to send after 00:01:00. Increase the timeout value passed to the call to Request or Increase the Sendtimeout value on the Binding. The time allotted to this Operation may have been a Portion of a longer timeout.

The error is this line even though I reported, to sign.

  • The 500 error you receive comes with some message?

  • No, no, no message. Debugging the code I see that it stops in this line that I mentioned in the question, and then returns the error, I believe for the delay, it needs to wait for the return to show the message.

  • When it is necessary to make many signatures, for example 50, it takes time, but when it is about 15, it gets the return, and works smoothly, only when it returns this error, and stops on this line.

  • I get it... so in this case I think it’s more related to the server side, right? It would not be better then to add the tag [tag:c-Sharp] and others related to your server side?

  • 1

    @Luizfelipe I changed some things in the code above, including the async and await, for now the error is the return of WCF, I will edit the question.

  • By default the sendTimeout of BasicHttpBindingand from 1 minute, what you can do and spend a new waiting time for it before the line you call the method is to put client.InnerChannel.OperationTimeout = new TimeSpan(0, 10, 0); in this example I am spending a waiting time of 10 minutes, anything is also just change in the time to pass the Binding.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.