Closed o7Ghost closed 2 years ago
Added in the documentation here: https://socketio.github.io/socket.io-client-java/faq.html#How_to_properly_close_a_client
One needs to manually shut down the ThreadPoolExecutor:
Dispatcher dispatcher = new Dispatcher();
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.dispatcher(dispatcher)
.readTimeout(1, TimeUnit.MINUTES) // important for HTTP long-polling
.build();
IO.Options options = new IO.Options();
options.callFactory = okHttpClient;
options.webSocketFactory = okHttpClient;
Socket socket = IO.socket(URI.create("https://example.com"), options);
socket.connect();
// then later
socket.disconnect();
dispatcher.executorService().shutdown();
Please reopen if needed.
Hello I'm fairly new to this so i made a simple program to learn. but it seems like when client disconnects from the server, The java program hangs for a bit before completely exits. I'm just wondering if this is normal? if not, how can i disconnect it properly so the java program immediately exits?
Client code
Server code