Occasional error when transmitting NFCe in the new RS - Connection Sefaz webservices

1

I have an NFe and NFCe issue system that we use for several RS clients. A few months ago, the company moved the webservices structure, so they also provided new URLs for access to the service (the old ones continue to run until the end of 2015). I've already downloaded the certificate chain and imported it into our trusted certificate store. I did some tests and had the following problem: Sometimes it works and sometimes it does not! Sometimes I send 5 notes and all are issued with no problem, and nothing starts to give error when connecting to WS. The error that happens (when it happens) is as follows:

INFO (11:19:42,368) - Unable to sendViaPost to url[https://nfce-homologacao.sefazrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx]
java.net.SocketException: Connection reset

I thought it might be something in my internet provider, but I tried to put it on some clients and the same problem occurs. Sometimes it is right and sometimes it is this error.

With the old URL everything worked 100%, this was when the old URL served both NFe and NFCe. Now with the new they have separated the services, and the new one from NFe works perfectly, the problem is only in the NFCe.

I talked to the staff of the committee and according to them it is no problem with them. However, they did not know to inform why the connection is sometimes not accepted. I also believe that it is not a problem in my code, since sometimes it works. But then I can not be too sure. Anyone know what could be happening?

    
asked by anonymous 10.07.2015 / 16:47

1 answer

2

Solved. I was using a class called SocketFactoryDinamico , which was a custom socket, to communicate with SEFAZ services. It turns out that in this class, there was a parameter that said which was the protocol of security in the communication, that when giving error was TLS. Switching to TLSv1 solved the problem:

SSLContext sslContext = SSLContext.getInstance("TLSv1");  

This problem happened a few months ago for NFCe in Rio Grande do Sul. Yesterday, 05/11/2015, also happened for all other SEFAZ services (NFe / CTe / MDFe, etc). The same fix applies to all of these services for those who also use Dynamic / Custom Socket on the connection.

Update

Actually the error only happened to happen from java 8, so if someone wants a temporary solution to the problem while not adjusting in the programming as I posted above, install java 7.

    
06.11.2015 / 19:31