Azure-Samples/SpeechToText-WebSockets-Javascript

exception of TypeError 'The header content contains invalid characters'

alanywlee opened this issue · 1 comments

I followed README instruction both in root and samples/browser directory to run
a server by "node sample-server.js enableTunnel" command, and trying to test by
speak some utterance. However my server always crashed by exception of TypeError
'The header content contains invalid characters' .

The following is the error message of crashed server:

Incoming request:/
Incoming request:/distrib/speech.sdk.bundle.js
Incoming request:/robots.txt?1517283192388
Incoming request:/favicon.ico
Incoming request:/token
_http_outgoing.js:359
    throw new TypeError('The header content contains invalid characters');
    ^

TypeError: The header content contains invalid characters
    at ClientRequest.OutgoingMessage.setHeader (_http_outgoing.js:359:11)
    at new ClientRequest (_http_client.js:85:14)
    at Object.exports.request (http.js:31:10)
    at Object.exports.request (https.js:202:15)
    at getToken (D:\JavaScript\SpeechToText-WebSockets-Javascript\samples\browser\sample-server.js:119:35)
    at Server.<anonymous> (D:\JavaScript\SpeechToText-WebSockets-Javascript\samples\browser\sample-server.js:43:9)
    at emitTwo (events.js:106:13)
    at Server.emit (events.js:191:7)
    at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:546:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)

PS: my node version is v6.11.3

Could you check if your speech.key contains any special symbols/whitespaces (cat -T speech.key). If it does not, make sure it's encoded using ascii:

> file -i speech.key
speech.key: text/plain; charset=us-ascii