Reputation: 56
I created IP Messaging Api code for Chat application. That code work on other server and done not work in amazon aws ec2 server. That gives error like,
cds.twilio.com/v2/Streams:1 POST https://cds.twilio.com/v2/Streams 403 (Forbidden) twilio-ip-messaging.min.js:150 IPMSG: failed to create session Object {status: 403, description: "Forbidden", body: "{"message":"Access forbidden","status":403}"}(anonymous function) @ twilio-ip-messaging.min.js:150 Uncaught (in promise) Object {status: 403, description: "Forbidden", body: "{"message":"Access forbidden","status":403}"} Uncaught (in promise) Object {status: 403, description: "Forbidden", body: "{"message":"Access forbidden","status":403}"} twilio-ip-messaging.min.js:151 Twilsock connection closed by server [].
Upvotes: 2
Views: 757
Reputation: 56
I found issue that i am using twilio-php library v9.
latest PHP Helper Library on your ECS server - which would be: 4.10.0
The latest version, or run Composer to get the latest version - as per https://www.twilio.com/docs/php/install#installation
https://github.com/twilio/twilio-php/archive/edge.zip
Upvotes: 0
Reputation: 10366
Twilio evangelist here.
If the code runs in a browser when served from one server but not from another server and you are getting 403's returned in the browser debug console as it looks like you are, the first thing I would check is that you are generating the IP Messaging Access Token correctly on the AWS server and that that token is being received by your client application correctly.
The errors you are receiving look like the Twilio IP Messaging JavaScript library is loading inthe browser and attempting to connect to the Twilio servers but not authenticating correctly, which usually means the token was not generated with the right data.
If your application expects to pull secrets like your AccountSid, ApiKey, Api Secret or Instance SID from environment variables, are you sure those exist in the AWS environment.
Hope that helps.
Upvotes: 1