Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Outbound Deadlock Issue #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kingster
Copy link

@kingster kingster commented May 26, 2019

The deadlock used to happen due to the clientHandler.onConnect handler being run on a sync thread. Hence any sync method would get blocked. AsyncApi still used to work, but the example provided was broken. With onConnect running on a separate thread the netty handler is released for further processing of responses which would complete the pending future.

Resolve #13

@kingster kingster changed the title Resolve Outbound Deadlock Issue ( Fixes #13) Resolve Outbound Deadlock Issue May 26, 2019
@@ -12,7 +14,8 @@
public class OutboundChannelInitializer extends ChannelInitializer<SocketChannel> {

private final IClientHandlerFactory clientHandlerFactory;
private ExecutorService callbackExecutor = Executors.newSingleThreadExecutor();
private ExecutorService callbackExecutor = Executors.newFixedThreadPool(2);
Copy link

@livem livem Jun 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can change the callbackExecutor with the method setCallbackExecutor outside whatever you want, without modify the OutboundChannelInitializer inside.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to modify the default callbackExecutor from SingleThreadExecutor to FixedThreadPool(2) for default execution by OutboundClientHandler, one being for handling ESL events and another for command-response. This is default behavior change hence changed here. Someone can still override and set it to much larger pool based on use-case by calling the setCallbackExecutor.

Incase you think this should be still newSingleThreadExecutor and OutboundClientHandler should all times override this, then I can make that change.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kingster Whenever you created a different EventExecutorGroup for the handler you don't need to make it two for the command-response messages. It will be handled by EventExecutorGroup thread

@livem
Copy link

livem commented Jun 4, 2019 via email

@livem
Copy link

livem commented Jun 4, 2019

Can you offer some Outbound Deadlock case ?
Some example code at FreeSWITCH side ?

<action application="socket" data="127.0.0.1:8084"/>

or

<action application="socket" data="127.0.0.1:8084 async"/> 

@kingster
Copy link
Author

kingster commented Jun 4, 2019

@livem This is what I am using at fs side

 <action application="socket" data="127.0.0.1:8084 async full"/>

@phyoo
Copy link

phyoo commented Jun 26, 2019

@livem This is what I am using at fs side

 <action application="socket" data="127.0.0.1:8084 async full"/>

I have changed the code just like you,and I am using it like

OutboundTest.java

and I am using it at fs side just like you too,but outbound still doesn't work.This is the fs's log:

2019-06-26 16:48:50.317129 [ERR] mod_event_socket.c:481 Socket Error: Connection refused
2019-06-26 16:48:50.317129 [ERR] mod_event_socket.c:485 Socket Error!

but when I am using

nc -l -k localhost 8084

it works.
any help?

@kingster
Copy link
Author

A Socket Error: Connection refused error would mean that the ESL destination is unreachable, please check your system firewall policies to allow the port. A localhost is a loopback address hence reachable directly

@kingster kingster closed this Jun 15, 2020
@kingster kingster deleted the outbound_fix branch June 15, 2020 10:33
@kingster kingster restored the outbound_fix branch June 25, 2020 10:14
@kingster kingster reopened this Jun 25, 2020
@ykalayy
Copy link

ykalayy commented Apr 29, 2022

@kingster
Seems this repo has been abandoned. I forked and fixed that memory leak issue & outbound deadlock issue with EvenLoopGroudExecutor. You can use my repository.
Welcome to contribute
https://github.com/ykalayy/esl-client

@kingster kingster mentioned this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Outbound doesn't work
5 participants