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

Having troubles to orignate #173

Open
disolaterX opened this issue Mar 29, 2024 · 3 comments
Open

Having troubles to orignate #173

disolaterX opened this issue Mar 29, 2024 · 3 comments

Comments

@disolaterX
Copy link

disolaterX commented Mar 29, 2024

newChannelKey := ari.NewKey(ari.ChannelKey, url.QueryEscape(fmt.Sprintf("channel:%s", endpoint+time.Now().String())))
log.Printf("Originate call to %s\n", newChannelKey)
channel, err := client.Channel().Originate(newChannelKey, ari.OriginateRequest{
  Endpoint:  endpoint,
  Extension: "s",
  Context:   "inbound",
  Priority:  1,
  CallerID:  endpoint, // Optional: Set CallerID if you want to override [email protected]
  Timeout:   30,
})

here endpoint value is

 PJSIP/superfone_number/sip:[email protected]: Non-2XX response: 400 Bad Request

the same work in dial() in extension but how to achive same where I want to call this [email protected] it exist on kamilio

(edited for formatting/readability)

@Ulexus
Copy link
Member

Ulexus commented Apr 7, 2024

That channel ID is a real mess, and while you are escaping it for URL usage, I suspect it is still going to have invalid characters from Asterisk's point of view.
There's a reason we have the rid package in this library: to construct resource IDs.

newChannelKey := ari.NewKey(ari.ChannelKey, rid.New(rid.Channel))

Then, if you really need to know the timestamp of that, you can get it back with:

ts, err := rid.Timestamp(newChannelKey.ID)

But that will give you a nice, completely valid channel ID with no special characters.

@Ulexus
Copy link
Member

Ulexus commented Apr 7, 2024

Oh, I think you're trying to pass the new, non-existent channel key into Originate as the first argument. The first argument to Originate is a related channel, from which ari can determine which Asterisk node to schedule it and from which Asterisk can determine how to most advantageously configure the new channel to work with it (such as avoiding transcoding).

See the comment on the Originate function: https://pkg.go.dev/github.com/CyCoreSystems/ari#Channel

@Ulexus
Copy link
Member

Ulexus commented Apr 7, 2024

If you don't have a related channel, just pass nil as the first argument.

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

No branches or pull requests

2 participants