Sunday, 22 September 2019

Connection lost - read ECONNRESET \ write EPIPE

I've built a controller like so in node js :

  *@UseGuards(AuthenticationGuard)
  @ApiOperation({ title: 'Add Refund', description: 'add new reund with file' })
  @HttpCode(HttpStatus.OK)
  @ApiResponse({
    status: HttpStatus.OK,
    description: 'Upload File Success',
  })
  @UseInterceptors(FileInterceptor('file',
  {
    storage: diskStorage({
      destination:  __dirname,//+"/../../../../" , 
      filename: (req, file, cb) => {
      const randomName = Array(32).fill(null).map(() => (Math.round(Math.random() * 16)).toString(16)).join('')
      return cb(null, `${randomName}${extname(file.originalname)}`)}
    }
    )}
    ))

  @HttpCode(HttpStatus.NOT_FOUND)
  @ApiResponse({
    status: HttpStatus.OK,
    description: 'Invalid Upload File',
  })
  @Post(refundsUrls.addRefund)
  doAddRefund( @Req() request,
    @Body('refund_type') refundType:number,
    @Body('currency_code') currencyId:number,
    @Body('amount') amount:number,
    @Body('flight_id') flightId:number,
    @Body('is_iai_card') isIaiCard:string,
     @Body('local_image_path') localImagePath:string,
    @Body('refund_date') refundDate:Date
    ,@UploadedFile() file): Promise<RefundDataInterface> {


      const { id } = request.user;
  return this.refundProvider.addRefund(id,refundType,currencyId,amount,flightId,isIaiCard,localImagePath,refundDate,file);

  }*

The method gets a few string parameters and a file , and saves the info in the DB, in my localhost it works well , but when I upload the code to the real server it crashes on this error :

"error": { "statusCode": 404, "message": "Error: Connection lost - read ECONNRESET",

or :

"error": { "statusCode": 404, "message": "Error: Connection lost - write EPIPE"

I can't manage to make this error on my debug local station , what might be the reason for this error ?



from Connection lost - read ECONNRESET \ write EPIPE

No comments:

Post a Comment