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?
– Luiz Felipe
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.
– Mariana
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.
– Mariana
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?
– Luiz Felipe
@Luizfelipe I changed some things in the code above, including the
async
andawait
, for now the error is the return of WCF, I will edit the question.– Mariana
By default the
sendTimeout
ofBasicHttpBinding
and from 1 minute, what you can do and spend a new waiting time for it before the line you call the method is to putclient.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.– Dionatas Firmino Machado