Docker Community Forums

Share and learn in the Docker community.

Empty body in Docker private registry notifications request to listener?


(Pardeep) #1

Hey,

I have setup a private registry v2 which is running inside a container and also setup a notification listener for it, which is written in nodejs. But the problem is that notification request body is always empty and i am not able to figure out the problem .
So any suggestion or help would be really helpful.

Thanks in advance


(Eric Robinson) #2

Were you able to figure this out ?


(Kpramesh2212) #3

I found the cause

if the application is node js then the data send by the registry is received as a buffer. All you should do is convert it back to String

Assuming that you have asked the private registry notification listener to send notification to the /notification url

Here is an example

app.post("/notification", function(req, res) {
    //If you use req.body it will print empty flower brackets
    console.log(req.body); // this will print empty {}
    //Instead use the below
    req.on(‘data’, function(data) { // data here is buffer
        console.log(data.toString(‘utf8’);
    });
    res.sendStatus(200);
});


(Adilm7177) #4

great resolve my issue thanks bro same problem with express node