I just followed the instructions to setup and test it. I used Javascript API. When I tried to message using two tabs or two windows as mentioned in the docs it is not working. It throws error at sendMessage method being "undefined". when I console log it gets the correct message typed in the html element.
As soon as I start localhost it throws following error. Any suggestions please.
Navigated to http://localhost:3000/
cds.twilio.com/v2/Streams:1 POST https://cds.twilio.com/v2/Streams 403 (Forbidden)
twilio-ip-messaging.min.js:198 IPMSG: failed to create session Object {status: 403, description: "Forbidden", body: "{"message":"Access forbidden","status":403}"}(anonymous function) # twilio-ip-messaging.min.js:198
undefined:1 Uncaught (in promise) Object {status: 403, description: "Forbidden", body: "{"message":"Access forbidden","status":403}"}
undefined:1 Uncaught (in promise) Object {status: 403, description: "Forbidden", body: "{"message":"Access forbidden","status":403}"}
undefined:1 Uncaught (in promise) Object {status: 403, description: "Forbidden", body: "{"message":"Access forbidden","status":403}"}
twilio-ip-messaging.min.js:199 Twilsock connection closed by server []r._onSocketRejected # twilio-ip-messaging.min.js:199d.create.callbacks.onsocketRejected # twilio-ip-messaging.min.js:199e.doCallback # twilio-ip-messaging.min.js:281e.afterThisEvent # twilio-ip-messaging.min.js:281e.afterEvent # twilio-ip-messaging.min.js:281transition # twilio-ip-messaging.min.js:281(anonymous function) # twilio-ip-messaging.min.js:281r.onmessage # twilio-ip-messaging.min.js:199
Twilio developer evangelist here.
First of all, you will need to use your production Account Sid in order to get this to work.
Twilio test credentials only work on certain parts of the REST API.
Once you have generated your token on the server side, you need to get it to the client side and authenticate your client like this:
accessManager = new Twilio.AccessManager(token);
messagingClient = new Twilio.IPMessaging.Client(accessManager);
Take a look at the IP Messaging quick start code to see an example of how it is done. The full instructions for the quick start guide can be found here.
Let me know if that helps at all.
Related
This unacceptable error occurs when using ytdl-core and telegraf javascript, all because of these two lines of code:
let video = ytdl('https://www.youtube.com/watch?v=ipAnwilMncI').pipe(fs.createWriteStream(`${ctx.from.id}.webm`));
ctx.replyWithVideo(video)
full text of the error:
C:\Program Files\nodejs\node.exe .\index.js
Uncaught TelegramError Error: 400: Bad Request: invalid file HTTP URL specified: Wrong port number specified in the URL
at callApi (node_modules\telegraf\lib\core\network\client.js:293:19)
at processTicksAndRejections (internal/process/task_queues:95:5)
Process exited with code 1
Node.js
I tried to send not as a video but as a document but it did not help
So I'm trying to use Axios to fetch some data before the test begins.
the test step is defined as follows
const axios = require('axios');
step("GET google", async function() {
await axios.get("https://www.google.com/")
});
And I have a test spec that looks like this
# Getting Started with Gauge
## GET google
* GET google
This is on a fresh Taiko/Gauge project. When running gauge runs specs I get the following error
Installing required plugins.
# Getting Started with Gauge
## GET google F
Failed Step: GET google
Specification: specs\test.spec:6
Error Message: AxiosError: Request failed with status code 400
Stacktrace:
And nothing else happens
im owning a Discord bot for music and stuff.
My console always gets spammed full with this message:
20:2:2022 - 17:22 | Info: [Slash Command]: [POST-FAILED] Guild 945348402374385736, Command: youtube
DiscordAPIError: Missing Access
at RequestHandler.execute (/home/m9mo/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async RequestHandler.push (/home/m9mo/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
at async /home/m9mo/util/RegisterSlashCommands.js:36:9 {
method: 'post',
path: '/applications/895283932252241940/guilds/945348402374385736/commands',
code: 50001,
httpStatus: 403
}
I know the reason for this error but some people are creating their own invite link using the id of the bot...
Is there any way to disable this message?
You could try finding the error code (In this case 50001) of that specific error, then when you receive an error, stop it from being logged. You can find all the relevant error codes here: https://discord.com/developers/docs/topics/opcodes-and-status-codes#json-json-error-codes
You might also want to consider sending some kind of message like I'm missing permission to do...
On the frontend of my application I use the #microsoft/signalr library to send off requests to my backend hubs. This works okay in a single tab, but when a second tab is open an error is outputted to the console of the first tab and the connection stops. It's almost as if the second tab is taking over for some reason, when really I believe both should be connected to the hub on different connections with different connection ids. The error I receive in the console is as follows:
[2021-04-23T09:34:22.762Z] Information: WebSocket connected to wss://localhost:6001/ptwHub?id=39HKWle3NU0eTjFxcNWsiQ.
Utils.js:218 [2021-04-23T09:34:32.895Z] Error: Connection disconnected with error 'Error: Message is incomplete.'.
./node_modules/#microsoft/signalr/dist/esm/Utils.js.ConsoleLogger.log # Utils.js:218
./node_modules/#microsoft/signalr/dist/esm/HttpConnection.js.HttpConnection.stopConnection # HttpConnection.js:542
transport.onclose # HttpConnection.js:479
./node_modules/#microsoft/signalr/dist/esm/WebSocketTransport.js.WebSocketTransport.close # WebSocketTransport.js:189
webSocket.onmessage # WebSocketTransport.js:129
ptw.ts:22 Error: Message is incomplete.
at Function../node_modules/#microsoft/signalr/dist/esm/TextMessageFormat.js.TextMessageFormat.parse (TextMessageFormat.js:13)
at JsonHubProtocol../node_modules/#microsoft/signalr/dist/esm/JsonHubProtocol.js.JsonHubProtocol.parseMessages (JsonHubProtocol.js:36)
at HubConnection../node_modules/#microsoft/signalr/dist/esm/HubConnection.js.HubConnection.processIncomingData (HubConnection.js:507)
at WebSocketTransport.HubConnection.connection.onreceive (HubConnection.js:73)
at WebSocket.webSocket.onmessage (WebSocketTransport.js:126)
The code to connect to the hub is as follows:
let connection = new signalR.HubConnectionBuilder().withUrl("https://localhost:6001/hub").build();
connection.on('knowledgeBaseUpdated', (userId: number) => {
alert(`User ${userId} has updated the knowledge base. Please refresh.`);
});
connection.start().catch(err => console.log(err));
Really not sure why the second tab would just take over the connection instead of creating a new connection. There is obviously an issue here somewhere but I'm really not sure where so any help would be really appreciated.
EDIT
I've enabled client side debugging for signalr and get the following output. The line which starts with HttpConnection.stopConnection is the line which appears when a new connections is attempted from a different tab.
[2021-04-26T09:50:00.084Z] Debug: Starting HubConnection.
Utils.js:228 [2021-04-26T09:50:00.096Z] Debug: Starting connection with transfer format 'Text'.
Utils.js:228 [2021-04-26T09:50:00.099Z] Debug: Sending negotiation request: https://localhost:6001/ptwHub/negotiate?negotiateVersion=1.
Utils.js:228 [2021-04-26T09:50:00.365Z] Debug: Selecting transport 'WebSockets'.
Utils.js:224 [2021-04-26T09:50:00.667Z] Information: WebSocket connected to wss://localhost:6001/ptwHub?id=14d1O9-cj544_-SHeZ2fgw.
Utils.js:228 [2021-04-26T09:50:00.667Z] Debug: The HttpConnection connected successfully.
Utils.js:228 [2021-04-26T09:50:00.668Z] Debug: Sending handshake request.
Utils.js:224 [2021-04-26T09:50:00.669Z] Information: Using HubProtocol 'json'.
Utils.js:228 [2021-04-26T09:50:13.079Z] Debug: Server handshake complete.
Utils.js:228 [2021-04-26T09:50:13.081Z] Debug: HttpConnection.stopConnection(Error: Message is incomplete.) called while in state Connected.
Utils.js:218 [2021-04-26T09:50:13.081Z] Error: Connection disconnected with error 'Error: Message is incomplete.'.
./node_modules/#microsoft/signalr/dist/esm/Utils.js.ConsoleLogger.log # Utils.js:218
./node_modules/#microsoft/signalr/dist/esm/HttpConnection.js.HttpConnection.stopConnection # HttpConnection.js:542
transport.onclose # HttpConnection.js:479
./node_modules/#microsoft/signalr/dist/esm/WebSocketTransport.js.WebSocketTransport.close # WebSocketTransport.js:189
webSocket.onmessage # WebSocketTransport.js:129
Utils.js:228 [2021-04-26T09:50:13.082Z] Debug: HubConnection.connectionClosed(Error: Message is incomplete.) called while in state Connecting.
Utils.js:228 [2021-04-26T09:50:13.083Z] Debug: Hub handshake failed with error 'Error: Message is incomplete.' during start(). Stopping HubConnection.
Utils.js:228 [2021-04-26T09:50:13.083Z] Debug: Call to HttpConnection.stop(Error: Message is incomplete.) ignored because the connection is already in the disconnected state.
Utils.js:228 [2021-04-26T09:50:13.084Z] Debug: HubConnection failed to start successfully because of error 'Error: Message is incomplete.'.
When the connection starts on a particular tab, I can see the connection has started and I get a single message when I look at the Network tab of Chrome Dev Tools. When I open the second tab, another message is sent to the first time which looks like an error message.. it weirdly contains a load of red dot characters? I
mage attached below. Please ignore the fact it's called ptwHub as I removed the ptw part previously to make it easier for the readers to understand.
Update w/ Additional Info - 18 Dec.
As I test further it appears that the error is isolated to the "this.response.end(json);" See notes below:
stripe non-invoice event:
a) "this.response.end(EJSON.stringify(obj, {indent: true}));" works & returns 200
b) "this.response.end(EJSON.stringify(obj));" no error on local server, error on stripe dashboard with 'unable to connect' and does not return code 200
stripe invoice event:
a) "this.response.end(EJSON.stringify(obj, {indent: true}));" throws errors - see details below.
b) "this.response.end(EJSON.stringify(obj));" no error on local server, error on stripe dashboard with 'unable to connect' and does not return code 200
Any insight would be appreciated.
I am having some issues with the Stripe API and am seeking some help or insight. I am using ngrok to test the Stripe webhooks locally and everything works fine until I make a request to any Stripe 'invoice' event type (e.g. invoice.payment_succeeded). When I run a test on any 'invoice' event type I get several errors:
my running application breaks (i.e. requires me to type meteor run in the terminal to restart the app)
I receive this server side error message in my terminal:
///error message start///
events.js:183
throw er; // Unhandled 'error' event
^
Error: write after end
at write_ (_http_outgoing.js:622:15)
at ServerResponse.write (_http_outgoing.js:617:10)
at IncomingMessage.ondata (_stream_readable.js:639:20)
at emitOne (events.js:116:13)
at IncomingMessage.emit (events.js:211:7)
at IncomingMessage.Readable.read (_stream_readable.js:475:10)
at flow (_stream_readable.js:846:34)
at resume_ (_stream_readable.js:828:3)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
///error message end///
On my Stripe dashboard I get an error: 'Test webhook error: Unable to connect'
Again this only breaks when I make a request to any Stripe 'invoice' event type (e.g. invoice.payment_succeeded).
I contacted Stripe to see if there was anything else I should consider but they said things were fine on their end.
One final point, to get ngrok running I use 'ngrok http 3000'.
With that said my server side webhook code is below. If anyone has any insight on what would be causing this error, any insight perspective would be appreciated.
///server side webhook code start///
Router.route('/webhooks/stripe', { where: 'server' })
.get(function () {
console.log('getter');
this.response.end('closing...');
})
.post(function () {
console.log('post function initiated');
// stores payload as string
var obj = this.request.body;
console.log("print obj var");
console.log(obj);
// saves as indented string to send as response
var json = EJSON.stringify(obj, {indent: true});
this.response.writeHead(200, {
'Content-Length': json.length,
'Content-Type': 'application/json'
});
this.response.end(json);
})
.put(function () {
console.log('put');
});
///server side webhook code end///
I was able to solve this issue. For reference and posterity I removed the commented code below and manually added my status code (i.e. this.response.statusCode = 200;). This got things working and resolved the issue.
///code snippet start///
var json = EJSON.stringify(obj, {indent: true});
//this is the code i removed
// this.response.writeHead(200, {
// 'Content-Length': json.length,
// 'Content-Type': 'application/json'
// });
//this is the code i added to send a manual status code
this.response.statusCode = 200;
this.response.end(json);
///code snippet end///