How does backup work with socket.io?

I would like to use WebSocketwith Java. The problem is that my server is separated from the client by a proxy server that cannot be configured. I was looking for implementations WebSocketwith backup moments, for example long-polling. I found socket.io, but don't know, how backup works.

In which case does it replace WebSocketand how?

Are there other libraries like socket.io with backup implementations? I would like to find one in Java, but I only found Jetty.

EDIT: Does backup only make browser dependency on WebSocket? What if the cause of the failure is a poorly configured proxy server, will the .io socket detect it as a compatibility failure and thus switch to a long polling (or other method)?

Answer: since v1, socket.io includes engine.io , which brings the following functions:

enter image description here

+4
source share
1 answer

Socket.io websockets, (IMO) - : , , .

, , socket.io websocket, , .

. , socket.io. HTTP → wait → response, , EOF . , , websockets ( TCP) , socket.io . , websockets , 2011 , . , socket.io , , "" .

websocket HTTP, . , http://localhost:8080 ( ). , , socket.io ws://localhost: 8080 .

socket.io, , HTTP- /-, .

, , - netty-socket.io. , :

public class Configuration {

    private ExceptionListener exceptionListener = new DefaultExceptionListener();

    private String context = "/socket.io";

    private List<Transport> transports = Arrays.asList(Transport.WEBSOCKET, Transport.POLLING);

    private int bossThreads = 0; // 0 = current_processors_amount * 2
    private int workerThreads = 0; // 0 = current_processors_amount * 2

.

Node JS -, , - ( Java):

io.set('transports', [                     // enable all transports (optional if you want flashsocket)
            'websocket'
          , 'flashsocket'
          , 'htmlfile'
          , 'xhr-polling'
          , 'jsonp-polling'
        ]);

, socket.io , , , , , .

, !

+7

Source: https://habr.com/ru/post/1609817/


All Articles