Comments (7)
Hello there,
this really sounds weird! can you reproduce the problem with a minimal test?
l.
from ari4java.
Hi Lenz,
Thanks for your reply. No, I can't. When I initially test my app based on your library, I executed 10 calls as maximum and anything works OK. Another member of my team try to test the app based on a stress scenario, and when the number of calls reach 100 calls that error is shown.
I suspect that the error could be due to the Netty Http Client, the pipeline handling is so confuse to me, and it could mess the streams. I'm creating a fork based on the apache http client to verify this. I will tell you my conclusion in the next days.
from ari4java.
Yes the Netty pipeline is a PITA. But it really sounds strange that things get mixed up....
from ari4java.
Hi Lenz,
I do the fork w/ Apache HTTP client, and works perfectly until 100 calls (I haven't tested with more calls, will do in the next hours). But, another problem that I detected is that the Actions that inherit from BaseAriAction will have serious syncronization problems, because the reset() method is called each time i need to execute a command over the ARI, and generates a nullpointerexception when another thread use it. I tried with the following two options:
- Synchronize the Action that I'm using (duh), but it will be a bottleneck if you have many threads/calls.
- Create an Action object each time I want to execute a command over the ARI, this should work nice but strangely it lets execute only 2 or 3 calls of 100. I don't have any idea why happens this.
I like to know your opinion about this scenario, and if you want some hand in development tasks I'm pleased to help you.
P.S. Your library is awesome!
from ari4java.
I am not sure I understand. Every time you want to run an action you run a different action, so there should be no synchronization issues. It is not meant to be reused.
from ari4java.
Hi Lenz, I tried to create a different "Action" object for each action to execute, but the result was unsuccessfull, only 3 calls of 100 was executed correctly. I assume that due to this you have in each Action a reset() method to use only one instance for action type (a kind of Singleton). I do several changes in the library, e.g. changing the websocket and http client, letting the Action as "static" classes, and another fixes, and the result was partly successfull in a stress test of 1000 calls / 50 concurrents. The error is mostly in the Asterisk, when the following error is showed several times: task processor queue reached 500 scheduled tasks, some Playbacks failed to play and so on.
from ari4java.
@Pablop992 I think your issue is you are re-using the object from ARI in multiple threads - that'll be a problem, you need a new object for each thread. The default EventLoop uses 2 times the CPUs reported by java (Runtime.getRuntime().availableProcessors()
) override this by suppling the system property io.netty.eventLoopThreads
. I set mine to 10 using -Dio.netty.eventLoopThreads=10
in the java
command you can also use System.setProperty("io.netty.eventLoopThreads", "10");
in your code.
bad (re-using channels object):
ARI ari = ARIFactory.nettyHttp(...);
ExecutorService executor = Executors.newFixedThreadPool(10);
ActionChannels channels = ari.channels();
for (int i=0; i < 100; i++) {
executor.execute(() -> {
channels.originate(...);
});
}
good (new channels object for each thread):
ARI ari = ARIFactory.nettyHttp(...);
ExecutorService executor = Executors.newFixedThreadPool(10);
for (int i=0; i < 100; i++) {
executor.execute(() -> {
ActionChannels channels = ari.channels();
channels.originate(...);
});
}
A suggestion on processing the ActionEvents is to create your own thread pool and schedule your application work in your own pool. I found that Asterisk doesn't send the next event until the previous one is complete. My onSuccess
looks similar to this:
ExecutorService executor = Executors.newFixedThreadPool(10);
AriCallback<Message> callback = new AriCallback<Message>() {
@Override
public void onSuccess(Message message) {
logger.debug("ARI onSuccess");
executor.execute(() -> {
if (message instanceof StasisStart) {
handleStatisStart((StasisStart) message);
}
});
}
@Override
public void onFailure(RestException e) {
logger.debug("ARI onFailure", e);
}
};
from ari4java.
Related Issues (20)
- Fix generated classes JavaDoc
- Getting HTTP 404 on endpoints request even though if a plain HTTP request returns the correct response HOT 2
- Channel not in stasis-application HOT 2
- Asterisk 17.3.0 Released HOT 1
- WS reconnect HOT 5
- onFailure is called a long time after the cause "WS Connect Error:"
- WS destroy HOT 4
- Hacktoberfest HOT 1
- How to set variables to channels with setChannelvars? HOT 1
- Migration to MavenCentral HOT 4
- Statement Fail - ariClient.playbacks().stop(playbackId).execute() - (DELETE /ari/playbacks HTTP/1.1) HOT 4
- ARI_6_0_0 channels API is missing the externalMedia call HOT 1
- Update to Netty 4.1.64 to prevent StackTraces in logs when using Java >= 11 HOT 1
- [BUG] ARI RTPStats Decode exception for remote_ssrc HOT 4
- N
- Netty RedTimeOut HOT 4
- Unable to get channelVars HOT 2
- Vagrant on Apple Silicon Changes
- protocol_id field in Channel_impl_ari_6_0_0 HOT 3
- Update API to 20.2? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ari4java.