react-softphone icon indicating copy to clipboard operation
react-softphone copied to clipboard

SoftPhone component invalid hook call error

Open RickGusG opened this issue 3 years ago • 13 comments

see in image below

image

RickGusG avatar Oct 04 '21 17:10 RickGusG

Your root project has different react version

Try yarn add [email protected] or npm i [email protected]

Meanwile i will fix

prinze77 avatar Oct 05 '21 12:10 prinze77

Your root project has different react version

Try yarn add [email protected] or npm i [email protected]

Meanwile i will fix

I am also facing the same issue. I tried with npm i [email protected] still it's not working.

mrvenom1994 avatar Oct 08 '21 08:10 mrvenom1994

I faced this problem too.

  1. npx create-react-app my-app --template typescript
  2. Edited App.tsx according to Usage and Issue https://github.com/prinze77/react-softphone/issues/10
  3. npm start
  4. Got an error: Error: Invalid hook call. Hooks can only be called inside of the body of a function component.

This is my config-object:

const config = {
    domain: '<some IP>', // [email protected]
    uri: 'sip:9000@<some IP>', // sip:[email protected]
    password: '<some password>', //  PASSWORD ,
    ws_servers: 'wss://9000@<some IP>:8089', //ws server
    sockets: new WebSocketInterface('wss://<some IP>:8089'),
    display_name: '9000',//jssip Display Name
    debug: false // Turn debug messages on
};

9000 - my internal Asterisk number. <some IP> - Asterisk server IP <some password> - password for 9000 number on Asterisk

And npm i [email protected] helped me. @prinze77, thank you.

Unfortunetly, I can't connect to my Asterisk. I am trying to solve this problem.

IBlasterus avatar Oct 27 '21 09:10 IBlasterus

Check the browser console log or the web socket messages in by pressing f12 in browser at network tab

Did you enabled the wss for 9000 extension in asterisk

prinze77 avatar Oct 27 '21 09:10 prinze77

Did you enabled the wss for 9000 extension in asterisk

Yes

Console: WebSocket connection to 'wss://<some IP>:8089/' failed: Asterisk: tcptls.c:845 handle_tcptls_connection: FILE * open failed from peer '<my IP>:<some port>'!

I am trying to solve this problem.

IBlasterus avatar Oct 27 '21 10:10 IBlasterus

Solve this problem. Asterisk couldn't access to private key and didn't listen wss.

Now I online, but can't call. Application error on screen. 2021-10-27_14-18

IBlasterus avatar Oct 27 '21 11:10 IBlasterus

Thank you for your feedback I know that there are dependencies issues and im fixing them right now

Concerning the error that you have at photo above

Try to add to the top of main page index.js or app.js import "babel-polyfill";

And at package.json

"dependencies": { "babel-polyfill": "^6.26.0", "jssip": "^3.8.2", "react": "^16.13.1", "react-dom": "^16.13.1", "react-scripts": "1.0.14", "react-softphone": "^1.6.0" },

prinze77 avatar Oct 27 '21 12:10 prinze77

Try to add to the top of main page index.js or app.js import "babel-polyfill";

What should I import from this library?

IBlasterus avatar Oct 27 '21 12:10 IBlasterus

Just like that

import "babel-polyfill";

More info here https://babeljs.io/docs/en/babel-polyfill/

prinze77 avatar Oct 27 '21 12:10 prinze77

import "babel-polyfill";

Did it.

When I tried imput number *43 for echo-test I got empty screen and errors in console (on photos). I even didn't have time to press the button.

2021-10-27_15-48 2021-10-27_15-48_1

IBlasterus avatar Oct 27 '21 12:10 IBlasterus

Check this boilerplate please

https://github.com/prinze77/my-app

Will it work on your machine? What node version you use?

prinze77 avatar Oct 27 '21 13:10 prinze77

It's works. You used base template create-react-app, without TypeScript?

Service-code *43 for echo-test doesn't work.

When it's rolled up, I can't see or hear the incoming call.

IBlasterus avatar Oct 27 '21 13:10 IBlasterus

You used base template create-react-app, without TypeScript?

Yes

When it's rolled up, I can't see or hear the incoming call.

Fixed, need to checkout

Service-code *43 for echo-test doesn't work.

Thats an input validation issue. The input can only validate numbers. I will make a fix by adding to validation * and #. https://github.com/prinze77/react-softphone/blob/bc90f008ebb113cb62d0337068647171e785d4ad/src/index.js#L518-L523 Thank you for finding this bug

prinze77 avatar Oct 27 '21 14:10 prinze77