IoTKETI / Mobius

oneM2M IoT Server Platform
http://developers.iotocean.org/archives/module/mobius
BSD 3-Clause "New" or "Revised" License
134 stars 87 forks source link

Error on CSR response handling #47

Open dima91 opened 3 years ago

dima91 commented 3 years ago

I encountered a problem performing a request to a remote CSE from a local platform. After having registered correctly the remote platform via MCC interface, I performed a discovery request to such platform. Target platform receives and handle well the request but, when the response arrives to the local platform, it crashes with this error:

mobius_1      | /home/node/Mobius/app.js:2598
mobius_1      |                                 var res = JSON.parse(JSON.stringify(_res));
mobius_1      |                                                           ^
mobius_1      | 
mobius_1      | TypeError: Converting circular structure to JSON
mobius_1      |     --> starting at object with constructor 'Socket'
mobius_1      |     |     property '_httpMessage' -> object with constructor 'ClientRequest'
mobius_1      |     --- property 'socket' closes the circle
mobius_1      |     at JSON.stringify (<anonymous>)
mobius_1      |     at /home/node/Mobius/app.js:2598:59
mobius_1      |     at IncomingMessage.<anonymous> (/home/node/Mobius/app.js:2725:13)
mobius_1      |     at IncomingMessage.emit (events.js:326:22)
mobius_1      |     at endReadableNT (_stream_readable.js:1252:12)
mobius_1      |     at processTicksAndRejections (internal/process/task_queues.js:80:21)
db_1          | 2021-06-10T07:56:13.296323Z 4 [Note] Aborted connection 4 to db: 'mobiusdb' user: 'root' host: '127.0.0.1' (Got an error reading communication packets)

By changing this line of app.js from

var res = JSON.parse(JSON.stringify(_res));

to

var res = _res;

the problem disappear. Could you please patch this problem? I have not enough rights.