cloudfoundry / service-fabrik-broker

Cloud Foundry service broker which provisions service instances as Docker containers and BOSH deployments.
Apache License 2.0
41 stars 50 forks source link

Broker sends empty response in case of request timeout #99

Closed pritishmishra closed 6 years ago

pritishmishra commented 6 years ago

Currently, the broker sends an empty HTTP Response code if any request sent to the broker times out. The time out for the broker is 120 seconds. If a request exceeds this time, an empty response with no body and no response code is received. More info here: https://github.com/expressjs/morgan/issues/121 “This happens when you do not write a response and allow the app to just hang. The reason you get the dashes is because since you didn't write a response, there is no response code, there is no response time, there is no response size, etc. Basically you are seeing all the properties of the response as dashes (i.e. unknown) and the properties of the request populated in that log.”

This has been observed to cause duplicate create calls from cf, as it expects a proper response from the broker, even if it times out. More info: https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#provisioning

Solution: We must do something like this from our end in case of timeouts: https://expressjs.com/en/resources/middleware/timeout.html to explicitly flag HTTP status of timeout.

mowi22 commented 5 years ago

I also wanted to leave this here for anyone that may have still gotten empty or pending responses from express. If you have not hung up the connection to the db before sending the response you will get pending request or a timeout after a while. I was making this mistake on a call and it resulted in -- ms -- from morgan mentioned here in this question . It had nothing to do with Morgan though. Here is a similar SO about it. Hope it helps someone. https://stackoverflow.com/questions/19397161/node-express-pending-request

LuisRuizUribeWicho12 commented 1 year ago

hola, ya hice la instalacion del connect-timeout y me sigue dando el mismo error, lo estoy trabajando con nodejs y postman al igual que con crome, te adjunto el codigo con el que estoy trabajando

const express = require('express'); const app = express(); const http = require('http'); const server = http.createServer(app); const logger = require('morgan'); const cors = require('cors');

const port = process.env.PORT || 3000;

app.use(logger('dev')); app.use(express.json); app.use(express.urlencoded({ extended: true })); app.use(cors());

app.disable('x-powered-by');

app.set('port',port);

server.listen(3000, 'aqui estoy trabando con la ip de mi computadora' || 'localhost', function() { console.log('Aplicacion de nodeJS '+ process.pid + ' Iniciada...........'); });

app.get('/', (req, res) => { res.send('Ruta raiz del backend'); });

//ERROR HANDLER

app.use((err, req, res, next) => { console.log(err); res.status(err.status || 500).send(err.stack); });

LuisRuizUribeWicho12 commented 1 year ago

analizando mi codigo me di cuenta que en la linea de app.use(express.json); me hacia falta el paréntesis al final del json por lo tanto quedaria de la siguiente manera app.use(express.json());, dejo esto por si alguien mas tiene el mismo error