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

New installation Asterlink [ SuiteCRM Version 7.12.7 / FreePBX -Asterisk 19.5.0 ] #13

Open
johanseld opened this issue Oct 16, 2022 · 23 comments

Comments

@johanseld
Copy link

johanseld commented Oct 16, 2022

FW Console - FreePBX Utility 16.0.21.18
Asterisk 19.5.0 built by mockbuild @ jenkins7 on a x86_64 running Linux on 2022-07-07 06:25:53 UTC
Server IP:172.16.34.21

SuiteCRM Version 7.12.7
Sugar Version 6.5.25 (Build 344)
Server IP:172.16.34.23

When I used the command ./Asterlink I am getting the following message error:

time="2022-10-16T14:40:02+02:00" level=info msg=AsterLink
time="2022-10-16T14:40:02+02:00" level=info msg="Setting log level" fields.level=trace
time="2022-10-16T14:40:02+02:00" level=info msg="Using SuiteCRM Connector"
time="2022-10-16T14:40:02+02:00" level=trace method=GET suite=true url="http://172.16.34.23/index.php?entryPoint=AsterLinkEntryPoint&action=get_ext_users"
time="2022-10-16T14:40:02+02:00" level=trace msg="200 OK" method=GET suite=true url="http://172.16.34.23/index.php?entryPoint=AsterLinkEntryPoint&action=get_ext_users"
time="2022-10-16T14:40:02+02:00" level=info msg="User list updated" suite=true users="map[2002:1]"
time="2022-10-16T14:40:02+02:00" level=info msg="Enabling web server" addr="172.16.34.23:5678" suite=true
**time="2022-10-16T14:40:02+02:00" level=fatal msg="listen tcp 172.16.34.23:5678: bind: cannot assign requested address" suite=true**
@johanseld johanseld changed the title I am getting the message when executed the command ./Asterlink I am getting the error message when executed the command ./Asterlink Oct 16, 2022
@serfreeman1337
Copy link
Owner

This error means that asterlink failed to start http api on address specified in endpoint_addr.
It may be that port 5678 is already taken or IP doesn't belong to server where asterlink is starting.

I.e. you should specify 172.16.34.21:5678, if you start asterlink on the same server with asterisk.
Also note that in order for popup card to work 172.16.34.21:5678 must be accessibly by user's browser.

@johanseld
Copy link
Author

I'm so confused about documentation.

what is the endpoint_addr? It´s the server where are installed Asterlink, PBX Server or SuiteCRM Module.

@serfreeman1337
Copy link
Owner

endpoint_addr in conf.yml is listen address for asterlink's HTTP api web server. You can specify 0.0.0.0:5678 so asterlink will be accessibly on 5678 tcp port on every IP addresses of a server.

Endpoint URL in suitecrm module settings is address of asterlink. SuiteCRM and user's web browser will connect to asterlink using this address.

If you start asterlink with endpoint_addr: 0.0.0.0:5678 on server with IP 172.16.34.21, then in suitecrm module settings you must specify 172.16.34.21:5678.

I'll try to make it more clear and easy to install in furuther releases.

@johanseld
Copy link
Author

Thank you.

ProxyPass "/asterlink/ws/" "ws://my_endpoint_addr:my_endpoint_port/ws/"
ProxyPass "/asterlink/" "http://my_endpoint_addr:my_endpoint_port/"

Where are the location "DocumentRoot" [/asterlink/ws/ & /asterlink/"] to configure the proxypass?

@serfreeman1337
Copy link
Owner

serfreeman1337 commented Oct 19, 2022

ProxyPass "/asterlink/ws/" "ws://172.16.34.21:5678/ws/"
ProxyPass "/asterlink/" "http://172.16.34.21:5678/"

It's apache2 config. Usually located at /etc/httpd/conf/httpd.conf or /etc/apache2/apache2.conf.
ProxyPass can also be put inside <VirtualHost> config (/etc/apache2/sites-available/000-default.conf etc.) for suitecrm, if you have one.

Also For ProxyPass to work following modules need to be enabled first: mod_proxy, mod_proxy_http, mod_proxy_wstunnel.

For Ubuntu execute following commands:

a2enmod proxy
a2enmod proxy_http
a2enmod proxy_wstunnel

Or simply uncomment them in httpd.conf (or apache2.conf) file:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Then you can update suitecrm module settings to use proxy:

Endpoint URL: http://172.16.34.23/asterlink
WebSocket URL: ws://172.16.34.23/asterlink

@johanseld johanseld changed the title I am getting the error message when executed the command ./Asterlink New installation Asterlink [ SuiteCRM Version 7.12.7 / FreePBX -Asterisk 19.5.0 ] Oct 19, 2022
@johanseld
Copy link
Author

I can be sure that what I do. I'll do the proxypass configuration in the server where I installed Asterlink or SuiteCRM Module?

@serfreeman1337
Copy link
Owner

On the SuiteCRM web-server. So, user will be able to reach asterlink via suitecrm webserver.

@johanseld
Copy link
Author

On the SuiteCRM Web-server, I configured the Proxy_pass but when tying to access from the SuiteCRM Web-server to http://myasterlink.myserver.lan:5678/asterlink give an error :404 page not found.

server {
    listen 80;
    server_name myasterlink.myserver.lan;
    }

    location /asterlink/ {
        proxy_pass http://172.16.34.21:5678/;
        proxy_redirect off;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header Host "myasterlink.myserver.lan";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }

@serfreeman1337
Copy link
Owner

serfreeman1337 commented Oct 20, 2022

give an error :404 page not found

That's ok, 404 page not found is from asterlink (if you access http://172.16.34.21:5678/ you will get same result).
At this point you should have click2call working.

For popup card you will also need to setup ws proxy.
Place it above location /asterlink/:

location /asterlink/ws/ {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;

    # enable WebSockets
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    proxy_pass http://172.16.34.21:5678;
}

SuiteCRM Module config:

  • Endpoint URL: http://myasterlink.myserver.lan/asterlink
  • WebSocket URL: ws://myasterlink.myserver.lan//asterlink

Also, those location rules are recommended to be placed inside nginx config for suitecrm. Overall it could look like this:

But it's also fine to use subdomain.

@johanseld
Copy link
Author

after setup setup ws proxy:

image

ws.js?v=wGrHdMwUNY-5ft4YcYeuoA:5 WebSocket connection to 'ws://myasterlink.myserver.lan/asterlink/ws/?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjEifQ.6hgFFl6riTZ6FYY0NITbyhpnP_D-tOxS3bHo-MJrnbM' failed: 
alWs @ ws.js?v=wGrHdMwUNY-5ft4YcYeuoA:5 "http://172.16.34.23/modules/AsterLink/javascript/ws.js?v=wGrHdMwUNY-5ft4YcYeuoA"

@serfreeman1337
Copy link
Owner

serfreeman1337 commented Oct 21, 2022

Here is correct proxy configuration (note the trailing / for proxy_pass):

location /asterlink/ws/ {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;

        # enable WebSockets
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_pass http://172.16.34.21:5678/ws/;
}

location /asterlink/ {
        proxy_pass http://172.16.34.21:5678/;
        proxy_redirect off;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header Host "myasterlink.myserver.lan";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
}

@johanseld
Copy link
Author

The same error:

ws.js?v=wGrHdMwUNY-5ft4YcYeuoA:5 WebSocket connection to 'ws://myasterlink.myserver.lan/asterlink/ws/?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjEifQ.6hgFFl6riTZ6FYY0NITbyhpnP_D-tOxS3bHo-MJrnbM' failed: 
alWs @ ws.js?v=wGrHdMwUNY-5ft4YcYeuoA:5

@serfreeman1337
Copy link
Owner

serfreeman1337 commented Oct 21, 2022

Is it still fails because of "404" ? Please check network tab on browser developer tools, it should show requests to myasterlink.myserver.lan.

Does click2call work ?

@johanseld
Copy link
Author

From the suitecrm server (172.16.34.23):

image
image

image

image

image

@serfreeman1337
Copy link
Owner

serfreeman1337 commented Oct 22, 2022

Can you show /asterlink/ws request ? Select "WS" on network tab to filter.
If it shows 403, then make sure that "endpoint_token" in conf.yml and "Token" in suitecrm module settings are both the same.

Also please show "Console" tab.

@johanseld
Copy link
Author

johanseld commented Oct 22, 2022

I exclude the servers to use proxy and now I don´t see any issues on browser developer tools.

@johanseld
Copy link
Author

I would like to thank you in advance for your support.

When I call to 478XXXXXX from SuiteCRM (my extension "2002") on my softphone I receive the call from my extension and when accept the incoming call the call going out.

image

My conf.yml

dialplan: 
  dial_context: from-internal
  ext_context: 
    - macro-dial-one
    - macro-dial
  incoming_context: 
    - from-pstn
  outgoing_context: 
    - macro-dialout-trunk
log_level: trace
suitecrm: 
  endpoint_addr: "0.0.0.0:5678"
  endpoint_token: my_endpoint_token
  url: "http://172.16.34.23/"

extensions_custom.conf

[assigned]
exten => 2002,1,Set(ASSIGNED=${CURL(http://172.16.34.23/asterlink/assigned/${UNIQUEID})})
exten => 2002,n,GotoIf($[${ASSIGNED}]?from-did-direct,${ASSIGNED},1)
exten => 2002,n,Goto(ext-queues,400,1)
exten => 2002,n,Hangup

extensions_additional.conf

exten => 2002,1,Set(__RINGTIMER=${IF($["${DB(AMPUSER/2002/ringtimer)}" > "0"]?${DB(AMPUSER/2002/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 2002,n,ExecIf($["${REGEX("from-queue" ${CHANNEL})}"="1" && "${CONTEXT}"="from-internal-xfer"]?Set(__CWIGNORE=))
exten => 2002,n,Macro(exten-vm,novm,2002,0,0,0)
exten => 2002,n(dest),Set(__PICKUPMARK=)
exten => 2002,n,GotoIf($["${IVR_CONTEXT}" != ""]?${IVR_CONTEXT},return,1)
exten => 2002,hint,PJSIP/2002&Custom:DND2002,CustomPresence:2002

sip_log.txt

@serfreeman1337
Copy link
Owner

When I call to 478XXXXXX from SuiteCRM (my extension "2002") on my softphone I receive the call from my extension and when accept the incoming call the call going out.

Yes, that how click2call is supposed to work. First it calls operator extension and on accept it calls clicked number.
I see that popup card's also working, meaning that asterlink's successfully configured.

@johanseld
Copy link
Author

Yes, that how click2call is supposed to work. First it calls operator extension and on accept it calls clicked number.
I see that popup card's also working, meaning that asterlink's successfully configured.

Yes, the outgoing call working but incoming call not. When the call operator receiving a call I can not see the popup card´s.

@serfreeman1337
Copy link
Owner

When the call operator receiving a call I can not see the popup card´s.

Does incoming call register in suitecrm's "call log" ? If not, check incoming context, it should match trunk's context.
For chan_sip it's context= line in incoming settings, for chan_pjsip it's Context on "pjsip Settings" tab. Usually it's from-pstn or from-trunk.

@johanseld
Copy link
Author

does incoming call register in suitecrm's "call log"

not, I chek the incoming context and its the same in trunks context "from-trunk".

@serfreeman1337
Copy link
Owner

trunks context "from-trunk".

You need to update incoming_context to from_trunk in conf.yml:

dialplan: 
  dial_context: from-internal
  ext_context: 
    - macro-dial-one
    - macro-dial
  incoming_context: 
    - from-trunk
  outgoing_context: 
    - macro-dialout-trunk
log_level: trace
suitecrm: 
  endpoint_addr: "0.0.0.0:5678"
  endpoint_token: my_endpoint_token
  url: "http://172.16.34.23/"

@johanseld
Copy link
Author

My conf.yml have this configuration.

dialplan: 
  dial_context: from-internal
  ext_context: 
    - macro-dial-one
    - macro-dial
  incoming_context: 
    - from-trunk
  outgoing_context: 
    - macro-dialout-trunk
log_level: trace
suitecrm: 
  endpoint_addr: "0.0.0.0:5678"
  endpoint_token: my_endpoint_token
  url: "http://172.16.34.23/"

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