Giter VIP home page Giter VIP logo

amiclient's People

Contributors

alexforster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amiclient's Issues

TCP zero window on Hi-load

Hi, when we user code on hi-load server(above 500 users and 50 CPS) Asterisk 18 is down:
AMI Manager freezes on command asterisk -rx "manager show connected".
What happens : AmiClient read messages from TCP stack on line 232 (master branch on 28/02/2022).
this.readBuffer = this.readBuffer.Append(bytes.Slice(0, nrBytes));
Then we try to find in Byte readBuffer TerminatorBytes. If we found it, then we pasre one line. If readBuffer contains several lines, we continiue parse other line.
At this time(when thread parse lines) in TCP buffer (TCP Window) we receive a lot of messages, which not receiving by ami client(because we parsing previous fragment of buffer).
Then we get issue : TCP zero window. This is mean, that receive from TCP buffer is very slowly.
image

Possible solution : use separate thread, which will be receive messages from TCP buffer into ConcurrentQueue and another thread, which will be get messages from queue and parse lines

The response is truncated, when the message exceeds the byte length(4096)

Some answers come truncated when it is very long.
For example:
await client.Publish(new AmiMessage { { "Action", "PJSIPShowContacts" } });

I need modify in AmiClient.cs
` try
{
var bytes = new Byte[4096];

 var nrBytes = this.stream.Read(bytes, 0, bytes.Length);
 if (nrBytes == 0)
 {
     yield break; // EOF
 }

 this.readBuffer = this.readBuffer.Append(bytes.Slice(0, nrBytes));

 this.DataReceived?.Invoke(this, new DataEventArgs(bytes.Slice(0, nrBytes)));

}`
to
try
{
var bytes = new Byte[12288];

 var nrBytes = this.stream.Read(bytes, 0, bytes.Length);
 if (nrBytes == 0)
 {
     yield break; // EOF
 }

 this.readBuffer = this.readBuffer.Append(bytes.Slice(0, nrBytes));

 this.DataReceived?.Invoke(this, new DataEventArgs(bytes.Slice(0, nrBytes)));

}

But it is inaccurate, since you do not know when you will need a higher value.

Sometimes events have the field "Response" (For example BridgeAction)

As per title, so in AmiClient.cs you can't just check for any Response Field.

I would suggest


if (message.Fields.Count > 0)
                    {
                        if (message.Fields.FirstOrDefault().Key.Equals("Response", StringComparison.CurrentCultureIgnoreCase) 
                            && message["ActionID"] != null && this.inFlight.TryGetValue(message["ActionID"], out var tcs))
                        {
                            tcs.SetResult(message);
                        }
                        else
                        {
                            this.Dispatch(message);
                        }
                    }

Hanging during login on asp.net core running in linux docker container

Actually this doesn't seem to have anything to do with docker or linux. The client works fine when I run the debug build but the release build it hangs on login. I was seeing a similar hang with AsterNET as well. I am starting to think that .net core release build has some issue with network streams.

Here is the output:
In: Asterisk Call Manager/3.2.0
Out: Action: Challenge
ActionID: b9e3e647-1c13-4095-8319-13638ef61c5d
AuthType: MD5

In: Response: Success
ActionID: b9e3e647-1c13-4095-8319-13638ef61c5d
Challenge: 119804922

how to get hang up event

i'm a newer of asterisk, could you show me an example of how to get hangup event with amiclient, i want to do something with the caller numer, thanks!

DataReceived not firing

After the initial events for login come in, no more events ever get fired, such as when a new call comes or someone hangs up.

Nuget package hangs on Login

Hi again.
Looks like your latest (1.2.3) nuget package hangs when trying to login. I don't know how to debug this, but it works when I clone your repo and add reference to it in my solution.

Not working AmiClient.Subscribe

I dont understand why method Subscribe not working. Example:
This code

var response = await amiClient.Where(message => message["Event"] == "Newstate").FirstAsync();
foreach (var item in response)
                {
                    Console.WriteLine(item.Key + ":" + item.Value);
                }

work good, but this:

var subscription = ami.Where(message => message["Event"] == "Newstate")
        .Subscribe(response =>
        {
            if (response != null)
            {
                foreach (var item in response)
                {
                    Console.WriteLine(item.Key + ":" + item.Value);
                }
            }
        });

not work.
I wait that this code wait all events "Newstate" and write to console. What am I doing wrong?

Exception if a host sends different handshake message

Hi.
I noticed that your code throws an exception if the first message server sends to you doesn't start with "Asterisk Call Manager". Is it really necessary to do this check? I'm trying to work with a kind of emulator of AMI but it's sending different first message, hence I can't make your library work with it.

Ergonomics of handling server failure

If the server the AmiClient is connected to closes the connection there is no way to find it out.
WorkerMain is throwing an exception, and it can't be caught because it is in a separate task.

Currently in case of closing the connection lineObserver.TakeUntil throws with an InvalidOperationException with a message "The sequence contains no elements").

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.