Re: Unix Sockets in Go

Ruel Tmeizeh via sr-users <[email protected]>
Newsgroups gmane.comp.voip.ser
Organization RuhNet
Message-ID <20250922213133.61cf43fa@x1y>
Check here for an example client:

https://github.com/cgrates/kamjsonrpc

-Ruel

Ruel Tmeizeh
RuhNet Consulting
https://ruhnet.co


On Mon, 22 Sep 2025 20:36:00 +0330
mohsen khashei via sr-users <[email protected]> wrote:

> Hi I want to run rpc commands like permissions.addressReload from a go
> application but with no luck please help me my code is:
> 
> 
> cmd:="permissions.addressReload"
> conn, err := net.Dial("unix", "/run/kamailio/kamailio_ctl")
> if err != nil {
> return "", fmt.Errorf("connect error: %w", err)
> }
> defer conn.Close()
> 
> // _, err = fmt.Fprintf(conn, "%s\n", cmd)
>  _, err = conn.Write([]byte(cmd))
>  if err != nil {
>      return "", fmt.Errorf("write error: %w", err)
>  }
> 
>  scanner := bufio.NewScanner(conn)
>  var output string
>  for scanner.Scan() {
>      output += scanner.Text() + "\n"
>  }
>  if err := scanner.Err(); err != nil {
>      return "", fmt.Errorf("read error: %w", err)
>  }
> 
> `
> the only thing i get is:
> ¡0#^@ ^A<90><91>^^bad request: corrupted packet^@

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the sender!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.