ampqlib Error:"Frame size exceeds frame max" inside docker container

555 Views Asked by At

I am trying to do simple application with backend on node.js + ts and rabbitmq, based on docker. So there are 2 containers: rabbitmq container and backend container with 2 servers running - producer and consumer. So now I am trying to get an access to rabbitmq server, but I get this error "Frame size exceeds frame max".

The full code is:

enter image description here

My producer server code is:

import express from 'express';
import amqplib, { Connection, Channel, Options } from 'amqplib';

const producer = express();

const sendRabbitMq = () =>{
    amqplib.connect('amqp://localhost', function(error0: any, connection: any) {
        if(error0){
            console.log('Some error...')
            throw error0
        }
    })
}

producer.post('/send', (_req, res) => {
    sendRabbitMq();
    console.log('Done...');
    res.send("Ok")
})

export { producer };

It is connected to main file index.ts and running inside this file. Also maybe I have some bad configuration inside docker. My Dockerfile is

FROM node:16

WORKDIR /app/backend/src

COPY *.json ./

RUN npm install

COPY . .

And my docker-compose include this code:

version: '3'

services:
  backend:
    build: ./backend 
    container_name: 'backend'
    command: npm run start:dev
    restart: always
    volumes:
      - ./backend:/app/backend/src
      - ./conf/myrabbit.conf:/etc/rabbitmq/rabbitmq.config
    ports:
      - 3000:3000
    environment:
      - PRODUCER_PORT=3000
      - CONSUMER_PORT=5672
    depends_on:
      - rabbitmq
      
  rabbitmq:
    image: rabbitmq:3.9.13
    container_name: 'rabbitmq'
    ports:
      - 5672:5672
      - 15672:15672
    environment:
      - RABBITMQ_DEFAULT_USER=user
      - RABBITMQ_DEFAULT_PASS=user

I will be very appreciated for your help

0

There are 0 best solutions below