Nexmo webSocket speech-to-text using voiceBase Api - vonage

I am trying to convert speech to text using voice base in nexmo. I have faced the issue in WebSocket client.
My response error is:
info: Server listening on:8900
info: A client is connected!
events.js:183
throw er; // Unhandled 'error' event
Error: This socket is closed
at Socket._writeGeneric (net.js:726:18)
at Socket._write (net.js:786:8)
at doWrite (_stream_writable.js:387:12)
at writeOrBuffer (_stream_writable.js:373:5)
at Socket.Writable.write (_stream_writable.js:290:11)
at Socket.write (net.js:704:40)
at WebSocketRequest.accept (/home/apptivo/Music/nexmoVoicebaseSample/Nexmo-RTS-Voicebase-master/WS-node/node_modules/websocket/lib/WebSocketRequest.js:450:21)
at WebSocketServer.handleUpgrade (/home/apptivo/Music/nexmoVoicebaseSample/Nexmo-RTS-Voicebase-master/WS-node/node_modules/websocket/lib/WebSocketServer.js:216:19)
at emitThree (events.js:141:20)
at Server.emit (events.js:217:7)
How to resolved this issue ???

I ran into this issue before (I am the developer of this project). Make sure your api keys are correct and are set in the .env file inside the WS-Node folder. It should be set to
ASR_URL={VOICEBASE_URL}
ASR_CLIENT_KEY={VOICEBASE_CLIENT_KEY}
ASR_CLIENT_SECRET={VOICEBASE_CLIENT_SECRET}

Related

Node.js Error: Unexpected server response: 301 - Running a Node.js Websocket server on Namecheap Webhost

I'm trying to setup a Node.js Websocket server over at my webhost (Namecheap). However, I am getting this error:
events.js:292
throw er; // Unhandled 'error' event
^
Error: Unexpected server response: 301
at ClientRequest.<anonymous> (D:\****\node_modules\ws\lib\websocket.js:576:7)
at ClientRequest.emit (events.js:315:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:596:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
at TLSSocket.socketOnData (_http_client.js:469:22)
at TLSSocket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at TLSSocket.Readable.push (_stream_readable.js:212:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)
Emitted 'error' event on WebSocket instance at:
at abortHandshake (D:\****\node_modules\ws\lib\websocket.js:694:15)
at ClientRequest.<anonymous> (D:\****\node_modules\ws\lib\websocket.js:576:7)
[... lines matching original stack trace ...]
at TLSSocket.Readable.push (_stream_readable.js:212:10)
The code for the client and server came from here:
https://github.com/websockets/ws#Simple server
https://github.com/websockets/ws#sending-and-receiving-text-data
with ws://www.host.com/path changed to ws://<mydomainname>/<dir1>/<dir2>
Both client and server code runs properly when run locally. Http related code runs properly when used on my webhost. I am trying to get the client code to run locally and connect via websockets to my server hosted at Namecheap.
I suspect something related to the server is preventing connection. I'd ask support but I doubt if they can resolve this. Maybe there's a locked feature or something? Is there something else I could have missed?
Websockets cannot work on Namecheap's hosted servers. Their incoming ports are blocked and cannot be opened for security reasons per their customer's support.
If anyone is looking for a solution just in case, try out a Heroku free account.

nodejs TLSSocket.onHangUp

I have 2 nodejs modules that communicate via HTTPS.
In very rare occasions, one of the requests to the server module returns:
Stack Trace
Error: socket hang up
at TLSSocket.onHangUp (_tls_wrap.js:1049:19)
at TLSSocket.g (events.js:260:16)
at emitNone (events.js:72:20)
at TLSSocket.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:913:12)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickDomainCallback (node.js:397:17)
with errno set to ECONNRESET
Is there any reason why something like that would happen?
I already checked for:
Server crashes before responding
Server response takes too long
certificate expired.
Also, the server logs do not show any kind of problem.
Thanks
ECONNRESET (Connection reset by peer): A connection was forcibly closed by a peer. This normally results from a loss of the connection on the remote socket due to a timeout or reboot. Commonly encountered via the http and net modules.
"Common System Errors" : https://nodejs.org/api/errors.html
so try first to see what's happen
process.on("uncaughtException", function (err) {
console.log('err uncaught Exception : ', err);
})

Twitter Stream & Node js server Error

I am trying to connect connect to twitter streaming api and I am getting the error
events.js:87
throw er; // Unhandled 'error' event
^
Error: Bad Twitter streaming request: 401
at ClientRequest.<anonymous> (/home/vikas/t4d/node_modules/twit/lib/oarequest.js:202:19)
at ClientRequest.g (events.js:201:16)
at ClientRequest.emit (events.js:109:17)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:421:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:113:23)
at TLSSocket.socketOnData (_http_client.js:312:20)
at TLSSocket.emit (events.js:109:17)
at readableAddChunk (_stream_readable.js:164:16)
at TLSSocket.Readable.push (_stream_readable.js:128:10)
at TCP.onread (net.js:540:20)
THe official api says it as Unauthorized access, but I am sure I have the right credentials (I have tested them before).
Also my www file has the entry
nconf.defaults({
'PORT': process.env.OPENSHIFT_NODEJS_PORT || process.env.PORT || 3000,
'BIND_IP': process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'
});
where putting 127.0.0.1 is also fine. I don't understand why I am getting the error and how to remove it ?
I am using the code for connecting from here. I have all the dependencies installed.
Thanks a lot for your help.
I patched this with updating the system time, it was delayed with 5 minutes. Since the date time is OK, the request is successful.

How to troubleshoot ECONNREFUSED error?

I'm trying to get the d3.js demo given here to work.
I'm following along the instructions in the README.md file. I get the npm install step to work, but the next step, node server, fails:
% node server
Master pid 16196
16197 listening. Go to: http://localhost:3030/
events.js:72
throw er; // Unhandled 'error' event
^
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
at RedisClient.on_error (/Users/yrstruly/tmp/derby-barchart/node_modules/redis/index.js:189:24)
at Socket.<anonymous> (/Users/yrstruly/tmp/derby-barchart/node_modules/redis/index.js:95:14)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:415:13)
It looks like the code is expecting to have some process listening to port 6379, but the README says nothing about this.
I'm quite unfamiliar with most of the software used by this demo. In particular, I know very little about node.js, derby, and redis. Therefore, I'm following the steps in the README rather blindly. Any help with troubleshooting this error would be appreciated.

"Unhandled stream error in pipe" from Node.js

My app: Node.js, Express, some middleware including connect-assets and express.static.
All running on local machine (OSX, Node 0.8) in development mode (thus express.static).
Probably important details: I recently made the whole app work through HTTPS (with redirect from HTTP when necessary) and while developing I use self-signe certificate (enabled in my browser, of course).
Now, the app is often failing wit stack traces like that:
(1)
stream.js:81
throw er; // Unhandled stream error in pipe.
^
Error: write EPIPE
at errnoException (net.js:769:11)
at Object.afterWrite (net.js:593:19)
(2)
stream.js:81
throw er; // Unhandled stream error in pipe.
^
Error: socket hang up
at SecurePair.error (tls.js:948:15)
at EncryptedStream.CryptoStream._done (tls.js:432:17)
at EncryptedStream.CryptoStream._pull (tls.js:577:12)
at SecurePair.cycle (tls.js:866:20)
at EncryptedStream.CryptoStream.end (tls.js:405:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
(3)
stream.js:81
throw er; // Unhandled stream error in pipe.
^
Error: socket hang up
at createHangUpError (http.js:1264:15)
at CleartextStream.socketCloseListener (http.js:1315:23)
at CleartextStream.EventEmitter.emit (events.js:126:20)
at SecurePair.destroy (tls.js:938:22)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Important: this happens often but not every time, so I assume this not to be a bug in my code.
I found this can be due to express.static and open files limit so I ran ulimit -n 10000 - with no effect, unfortunately.
Any ideas? This starts to be extremely frustrating.
OK, looks like I found the answer (at least I found a similar problem mentioned, tried their fix and it stopped falling):
the express.static middleware must be the last in the chain

Resources