Error parsing HTTP request header with dockerized application

Hi,
I have deployed my OpenVidu application and OpenVidu platform to AWS as told in these links:
https://docs.openvidu.io/en/2.14.0/deployment/deploying-aws/
https://docs.openvidu.io/en/2.14.0/deployment/deploying-openvidu-apps/
The OpenVidu Call application works fine along with the test in /dashboard/ .

But when I deploy my dockerized OpenVidu application, I get this error when joining / creating a meeting:

openvidu-server_1 | [INFO] 2020-06-11 15:36:27,932 [0.0-5443-exec-1] org.apache.coyote.http11.Http11Processor - Error parsing HTTP request header openvidu-server_1 | Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level. openvidu-server_1 | java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens openvidu-server_1 | at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:415) openvidu-server_1 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:260) openvidu-server_1 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) openvidu-server_1 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) openvidu-server_1 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1598) openvidu-server_1 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) openvidu-server_1 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) openvidu-server_1 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) openvidu-server_1 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) openvidu-server_1 | at java.lang.Thread.run(Thread.java:748)

What am I doing wring here?
Thanks

I have even tried installing natively:
https://docs.openvidu.io/en/2.14.0/deployment/deploying-openvidu-apps/#installed-natively
I am getting an error, which might be the same one before but here are the logs:

<ref *2> Writable {
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
errored: false,
closed: false
},
_events: [Object: null prototype] {
response: [Function: handleResponse],
error: [Function: handleRequestError]
},
_eventsCount: 2,
_maxListeners: undefined,
_options: {
protocol: 'https:',
maxRedirects: 21,
maxBodyLength: 10485760,
path: '/api/sessions',
method: 'POST',
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
Authorization: 'Basic T1BFTlZJRFVBUFA6ZTRlNW5mM25jNmJjNGJjNWI0',
'User-Agent': 'axios/0.19.2',
'Content-Length': 160
},
agent: undefined,
agents: { http: undefined, https: undefined },
auth: undefined,
hostname: 'localhost',
port: '5443',
nativeProtocols: { 'http:': [Object], 'https:': [Object] },
pathname: '/api/sessions'
},
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 160,
_requestBodyBuffers: [
{
data: <Buffer 7b 22 6d 65 64 69 61 4d 6f 64 65 22 3a 22 52 4f 55 54 45 44 22 2c 22 72 65 63 6f 72 64 69 6e 67 4d 6f 64 65 22 3a 22 4d 41 4e 55 41 4c 22 2c 22 64 65 ... 110 more bytes>,
encoding: undefined
}
],
_onNativeResponse: [Function (anonymous)],
_currentRequest: <ref *1> ClientRequest {
_events: [Object: null prototype] {
response: [Function],
socket: [Function (anonymous)],
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
error: [Function (anonymous)],
timeout: [Function (anonymous)]
},
_eventsCount: 6,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: false,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
secureConnecting: true,
_SNICallback: null,
servername: null,
alpnProtocol: null,
authorized: false,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 10,
connecting: false,
_hadError: true,
_parent: null,
_host: 'localhost',
_readableState: [ReadableState],
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: false,
parser: null,
_httpMessage: [Circular *1],
[Symbol(res)]: [TLSWrap],
[Symbol(verified)]: false,
[Symbol(pendingSession)]: null,
[Symbol(async_id_symbol)]: 239,
[Symbol(kHandle)]: null,
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 417,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 417,
[Symbol(connect-options)]: [Object]
},
_header: 'POST /api/sessions HTTP/1.1\r\n' +
'Accept: application/json, text/plain, */*\r\n' +
'Content-Type: application/json\r\n' +
'Authorization: Basic T1BFTlZJRFVBUFA6ZTRlNW5mM25jNmJjNGJjNWI0\r\n' +
'User-Agent: axios/0.19.2\r\n' +
'Content-Length: 160\r\n' +
'Host: localhost:5443\r\n' +
'Connection: close\r\n' +
'\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: [Object],
freeSockets: {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/api/sessions',
_ended: false,
res: null,
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
_redirectable: [Circular *2],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [Array],
'content-type': [Array],
authorization: [Array],
'user-agent': [Array],
'content-length': [Array],
host: [Array]
}
},
_currentUrl: 'https://localhost:5443/api/sessions',
[Symbol(kCapture)]: false
}
Error: [object Object]
at /opt/openvidu/project/node_modules/openvidu-node-client/lib/Session.js:421:28
at processTicksAndRejections (internal/process/task_queues.js:97:5)

But still I am not able to debug this issue :frowning:
EDIT:
It seems like I get the same error locally, but is solved by using a HTTPS server, but over here, it says to have a HTTP server for deployment. By the way, The error comes when executing this line:
OV.createSession()

Thanks

but over here, it says to have a HTTP server for deployment.

It works with plain http because there’s an nginx docker container that redirects https petitions from
port 443 to the application running at port 5442.

It seems like your application is not doing well requests to openvidu server. I guess by the log you’ve written that you’re making HTTPS requests to your OpenVidu server from your server app, but you should use HTTP. In fact, the openvidu url should be:
http://localhost:5443
Your app should request this url. Be sure that your app, in production, make requests to this url.

Hi,
Thanks for the reply,
I had tried with http://localhost:5443 before and it did not work, so I tried with https
Any way here is the log for using http:

_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
errored: false,
closed: false
},
_events: [Object: null prototype] {
response: [Function: handleResponse],
error: [Function: handleRequestError]
},
_eventsCount: 2,
_maxListeners: undefined,
_options: {
protocol: 'https:',
maxRedirects: 21,
maxBodyLength: 10485760,
path: '/api/sessions',
method: 'POST',
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
Authorization: 'Basic T1BFTlZJRFVBUFA6ZTRlNW5mM25jNmJjNGJjNWI0',
'User-Agent': 'axios/0.19.2',
'Content-Length': 160
},
agent: undefined,
agents: { http: undefined, https: undefined },
auth: undefined,
hostname: 'localhost',
port: '5443',
nativeProtocols: { 'http:': [Object], 'https:': [Object] },
pathname: '/api/sessions'
},
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 160,
_requestBodyBuffers: [
{
data: <Buffer 7b 22 6d 65 64 69 61 4d 6f 64 65 22 3a 22 52 4f 55 54 45 44 22 2c 22 72 65 63 6f 72 64 69 6e 67 4d 6f 64 65 22 3a 22 4d 41 4e 55 41 4c 22 2c 22 64 65 ... 110 more bytes>,
encoding: undefined
}
],
_onNativeResponse: [Function (anonymous)],
_currentRequest: <ref *1> ClientRequest {
_events: [Object: null prototype] {
response: [Function],
socket: [Function (anonymous)],
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
error: [Function (anonymous)],
timeout: [Function (anonymous)]
},
_eventsCount: 6,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: false,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
secureConnecting: true,
_SNICallback: null,
servername: null,
alpnProtocol: null,
authorized: false,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 10,
connecting: false,
_hadError: true,
_parent: null,
_host: 'localhost',
_readableState: [ReadableState],
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular *1],
[Symbol(res)]: [TLSWrap],
[Symbol(verified)]: false,
[Symbol(pendingSession)]: null,
[Symbol(async_id_symbol)]: 165,
[Symbol(kHandle)]: null,
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 417,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 417,
[Symbol(connect-options)]: [Object]
},
_header: 'POST /api/sessions HTTP/1.1\r\n' +
'Accept: application/json, text/plain, */*\r\n' +
'Content-Type: application/json\r\n' +
'Authorization: Basic T1BFTlZJRFVBUFA6ZTRlNW5mM25jNmJjNGJjNWI0\r\n' +
'User-Agent: axios/0.19.2\r\n' +
'Content-Length: 160\r\n' +
'Host: localhost:5443\r\n' +
'Connection: close\r\n' +
'\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: [Object],
freeSockets: {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/api/sessions',
_ended: false,
res: null,
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
_redirectable: [Circular *2],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [Array],
'content-type': [Array],
authorization: [Array],
'user-agent': [Array],
'content-length': [Array],
host: [Array]
}
},
_currentUrl: 'https://localhost:5443/api/sessions',
[Symbol(kCapture)]: false
}
Error: [object Object]
at /opt/openvidu/project/node_modules/openvidu-node-client/lib/Session.js:421:28
at processTicksAndRejections (internal/process/task_queues.js:97:5)

Thanks

You’re right. I’ve check our openvidu-node-client, and version 2.14.0 is forcing https. We’ve fixed this for version 2.15.0 that is coming out soon :slight_smile:

A workaround you can do, is to use the public url of your openvidu-server. So for example if your application is deployed with a domain name like: example.com you should put this in your docker-compose.override.yml:

environment:
            - SERVER_PORT=5442
            - OPENVIDU_URL=https://example.com
            - OPENVIDU_SECRET=${OPENVIDU_SECRET}

On version 2.15.0 you should be able to use http://localhost:5443

1 Like

Same bug: Node-client: GetSession Fails in production for custom dockerized app (Bug?)

Hi,
Sorry for not seeing that topic before.
I tried the workaround you provided. It stoped the error :grinning:, but the web page gives a timeout. There are no errors in the log though.

By the way, Is there a way to access the logs given from my node application if I am using docker?
Thanks

$ docker logs

1 Like

Thanks,
I have (possibly) debugged the issue.
One more question, I have a mongodb docker container alongside my app like:

version: '3.1'

services:
    mongodb:
        image: mongo

    app:
        image: (docker image)
        restart: on-failure
        network_mode: host
        environment:
            - SERVER_PORT=5442
            - OPENVIDU_URL=https://localhost:5443
            - OPENVIDU_SECRET=${OPENVIDU_SECRET}

I am not able to access the MongoDB container to store information. I have tried connecting to the following urls with my node application (mongoose):

  • mongodb://mongodb:27017/DatabaseName
  • mongodb://openvidu_mongodb_1:27017/DatabaseName

But both do not work.
Is it by any chance that 27017 is a blocked port?

You should configure mongo with

network_mode: host

And use “localhost” as host to connect to it from your app container.

Regards

Hi,
I just solved it by running a mongo image in detach mode and using localhost to connect :grinning:
Thanks Anyway

2 Likes