moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 508 forks source link

Can Mosca talk to Azure/DocDB MongoDB API? #599

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi,

I am trying to get Mosca to talk to the DocumentDB in the Azure cloud. I just tried the code from https://github.com/mcollina/mosca/wiki/Mosca-basic-usage#lets-put-it-all-together-now which works fine locally but fails when replacing the urls with the DocDB connection strings. The error seems pretty generic:

$ node index.js                                                  
/local/azure/eventProcessor/node_modules/mongodb/lib/utils.js:98
    process.nextTick(function() { throw err; });
    ^                                                                              

Error: Cannot recover. Collection is not capped.
    at /local/azure/eventProcessor/node_modules/ascoltatori/lib/mongo_ascoltatore.js:241:26                                                                        
    at handleCallback (/local/azure/eventProcessor/node_modules/mongodb/lib/utils.js:95:56)                                               
    at /local/azure/eventProcessor/node_modules/mongodb/lib/collection.js:1559:5                                                                   
    at handleCallback (/local/azure/eventProcessor/node_modules/mongodb/lib/utils.js:95:56)                                               
    at /local/azure/eventProcessor/node_modules/mongodb/lib/collection.js:1528:5                                                                   
    at handleCallback (/local/azure/eventProcessor/node_modules/mongodb/lib/utils.js:95:56)                                               
    at /local/azure/eventProcessor/node_modules/mongodb/lib/cursor.js:852:16                                                                  
    at handleCallback (/local/azure/eventProcessor/node_modules/mongodb-core/lib/cursor.js:171:5)                                        
    at setCursorDeadAndNotified (/local/azure/eventProcessor/node_modules/mongodb-core/lib/cursor.js:506:3)                              
    at nextFunction (/local/azure/eventProcessor/node_modules/mongodb-core/lib/cursor.js:652:7)                                          
    at Cursor.next [as _next] (/local/azure/eventProcessor/node_modules/mongodb-core/lib/cursor.js:693:3)                                
    at fetchDocs (/local/azure/eventProcessor/node_modules/mongodb/lib/cursor.js:848:10)                                                       
    at /local/azure/eventProcessor/node_modules/mongodb/lib/cursor.js:871:7                                                                 
    at handleCallback (/local/azure/eventProcessor/node_modules/mongodb-core/lib/cursor.js:171:5)                                        
    at nextFunction (/local/azure/eventProcessor/node_modules/mongodb-core/lib/cursor.js:683:5)                                          
    at /local/azure/eventProcessor/node_modules/mongodb-core/lib/cursor.js:594:7                                                        
    at queryCallback (/local/azure/eventProcessor/node_modules/mongodb-core/lib/cursor.js:253:5)                                      
    at /local/azure/eventProcessor/node_modules/mongodb-core/lib/connection/pool.js:457:18                                             
    at nextTickCallbackWith0Args (node.js:419:9)                                                                                       
    at process._tickCallback (node.js:348:13)

This is with the connection string like mongodb://{user}:{password}@{ressource_name}.documents.azure.com:10250/?ssl=true

If I change the ssl=false, it worked for a few minutes yesterday but today it will time out on connection.

I also tried to implement https://github.com/mcollina/mosca/wiki/TLS-SSL-Configuration but failed to understand how to obtain the correct cert and key from the cloud host.

I would be thankful for a pointer in the right direction.

Regards Frederik

mcollina commented 7 years ago

Mosca works with Capped Collections. If DocumentDB in the Azure cloud does not support capped collections, it cannot be used.