Answered

Node Custom Connector Problem

I have experience with node but I'm new to Bizagi. I've been trying to create a custom connector for Bizagi Studio using this npm package: https://www.npmjs.com/package/imgur

The problem arises when I attach the connector with Bizagi Studio and create a new case to test the functionality: It just hangs. I have not been able to figure out "what" or "why". I've read the documentation but It hasn't been really helpful.

From what I understand the connector should log some outputs but they are never generated.

I have tested the connector isolated (without Bizagi Studio) and it works perfectly with Node v0.12.5 and v7. Any Help is appreciated.

upload-from-url.js:

  1. var bzutil = require('bz-util'),

    imgur = require('imgur');

    var BzError = bzutil.error,

    BzResponse = bzutil.getResponse;

    /**

    * @author C. Lobo

    */

    exports.invoke = function(globals, actionName, data, authenticationType, logger, done) {

    var email = globals.authdata.email,

    password = globals.authdata.password,

    clientId = globals.authdata.clientId,

    url = data.inputs.input.url,

    bzErrorMessage;

    imgur.setCredentials(email, password, clientId);

    imgur.setAPIUrl('https://api.imgur.com/3/');

    imgur.uploadUrl(url)

    .then(function(res) {

    logger.info(JSON.stringify(res));

    logger.debug(JSON.stringify(res));

    done(BzResponse(res, null, 200));

    })

    .catch(function(res) {

    logger.error(JSON.stringify(res));

    bzErrorMessage = res.code === "ENOTFOUND" ?

    BzError('GLB.RESPONSE_ERROR', [res.message]) :

    BzError('GLB.RESPONSE_ERROR', [res.status, res, res.data.error])

    done(BzResponse(null, res, res.status, bzErrorMessage));

    });

    };

170228113051_51_IN0_ImgurConnector_upload-url:

  1. {

    "UploadImageFromURL": {

    "@key": "51",

    "URL": "http://40.media.tumblr.com/7a88d1fe913190782b17ac85574d7830/tumblr_ny71ov48yK1tx45yjo3_1280.jpg";

    }

    }

170228113051_51_IN1_ImgurConnector_upload-url:

  1. {

    "inputs": {

    "input": {

    "url": "http://40.media.tumblr.com/7a88d1fe913190782b17ac85574d7830/tumblr_ny71ov48yK1tx45yjo3_1280.jpg";

    }

    }

    }

BATrace_Web_2017228.txt:

  1. #Software: Bizagi Web
  2. #Version: 11.0.0.2645
  3. #Platform: CLR 4.0.30319.42000
  4. #OSVersion: Microsoft Windows NT 6.2.9200.0
  5. #Machine: DESKTOP-HVGS0B1
  6. #ProcessorCount: 8
  7. #User Name: Carlos camilo
  8. #Domain: DESKTOP-HVGS0B1
  9. #Fields: date time session level module submodule message
  10. 2017-02-28 22:49:06.760 None INFO WORKFLOW------------ -------------------- BEGIN: Create Process Instance
  11. 2017-02-28 22:49:06.770 None INFO WORKFLOW------------ -------------------- Begin transaction
  12. 2017-02-28 22:49:06.770 None INFO WORKFLOW------------ -------------------- Get Process Definition
  13. 2017-02-28 22:49:07.060 None INFO WORKFLOW------------ -------------------- Create Process: 1
  14. 2017-02-28 22:49:07.068 None INFO WORKFLOW------------ -------------------- Set case scope checkPoint
  15. 2017-02-28 22:49:07.261 None INFO WORKFLOW------------ -------------------- BEGIN: Executing task id=4 Name=Event_1 DisplayName=Start on EventTypeOnEnter
  16. 2017-02-28 22:49:07.365 None INFO RULES--------------- -------------------- START EXECUTING RULE True, ID 1000
  17. 2017-02-28 22:49:07.372 None INFO RULES--------------- -------------------- END EXECUTING RULE True, ID 1000
  18. 2017-02-28 22:49:07.373 None INFO WORKFLOW------------ -------------------- Executing transition id=2 Name=Element_1 DisplayName=
  19. 2017-02-28 22:49:07.380 None INFO WORKFLOW------------ -------------------- BEGIN: Executing task id=4 Name=Event_1 DisplayName=Start on EventTypeOnExit
  20. 2017-02-28 22:49:07.381 None INFO WORKFLOW------------ -------------------- END
  21. 2017-02-28 22:49:07.549 None INFO WORKFLOW------------ -------------------- END
  22. 2017-02-28 22:49:07.550 None INFO WORKFLOW------------ -------------------- Commit data
  23. 2017-02-28 22:49:07.679 None INFO WORKFLOW------------ -------------------- Commit transaction
  24. 2017-02-28 22:49:07.680 None INFO WORKFLOW------------ -------------------- END
  25. 2017-02-28 22:50:12.901 None INFO WORKFLOW------------ -------------------- BEGIN: CWorkflowManager.internal_doWorkItemById :: WorkItemId=2 - ProcId=1 - User=-1
  26. 2017-02-28 22:50:12.901 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: preOperationLoad
  27. 2017-02-28 22:50:12.901 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: beginTransaction
  28. 2017-02-28 22:50:12.901 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: CProcessManager.getProcessInstance
  29. 2017-02-28 22:50:12.901 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: checkForProcessActivation
  30. 2017-02-28 22:50:12.901 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: process.persistProcess
  31. 2017-02-28 22:50:12.902 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: process.ProcessState=Running
  32. 2017-02-28 22:50:12.902 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: process.doWorkItemById(idWorkitem, appEntity, alTransitionIds)
  33. 2017-02-28 22:50:12.904 None INFO WORKFLOW------------ -------------------- activating workitem
  34. 2017-02-28 22:50:12.905 None INFO RULES--------------- -------------------- START EXECUTING RULE True, ID 1000
  35. 2017-02-28 22:50:12.906 None INFO RULES--------------- -------------------- END EXECUTING RULE True, ID 1000
  36. 2017-02-28 22:50:12.906 None INFO WORKFLOW------------ -------------------- Executing transition id=1 Name=Element_2 DisplayName=
  37. 2017-02-28 22:50:13.016 None INFO RULES--------------- -------------------- START EXECUTING RULE True, ID 1000
  38. 2017-02-28 22:50:13.016 None INFO RULES--------------- -------------------- END EXECUTING RULE True, ID 1000
  39. 2017-02-28 22:50:13.016 None INFO WORKFLOW------------ -------------------- Executing transition id=3 Name=Element_3 DisplayName=
  40. 2017-02-28 22:50:13.093 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: postOperationSave
  41. 2017-02-28 22:50:13.093 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: commitTransaction
  42. 2017-02-28 22:50:13.100 None INFO WORKFLOW------------ -------------------- END
  43. 2017-02-28 22:50:23.192 None INFO WORKFLOW------------ -------------------- BEGIN: Create Process Instance
  44. 2017-02-28 22:50:23.192 None INFO WORKFLOW------------ -------------------- Begin transaction
  45. 2017-02-28 22:50:23.193 None INFO WORKFLOW------------ -------------------- Get Process Definition
  46. 2017-02-28 22:50:23.194 None INFO WORKFLOW------------ -------------------- Create Process: 2
  47. 2017-02-28 22:50:23.194 None INFO WORKFLOW------------ -------------------- Set case scope checkPoint
  48. 2017-02-28 22:50:23.197 None INFO WORKFLOW------------ -------------------- BEGIN: Executing task id=4 Name=Event_1 DisplayName=Start on EventTypeOnEnter
  49. 2017-02-28 22:50:23.199 None INFO RULES--------------- -------------------- START EXECUTING RULE True, ID 1000
  50. 2017-02-28 22:50:23.200 None INFO RULES--------------- -------------------- END EXECUTING RULE True, ID 1000
  51. 2017-02-28 22:50:23.200 None INFO WORKFLOW------------ -------------------- Executing transition id=2 Name=Element_1 DisplayName=
  52. 2017-02-28 22:50:23.201 None INFO WORKFLOW------------ -------------------- BEGIN: Executing task id=4 Name=Event_1 DisplayName=Start on EventTypeOnExit
  53. 2017-02-28 22:50:23.202 None INFO WORKFLOW------------ -------------------- END
  54. 2017-02-28 22:50:23.211 None INFO WORKFLOW------------ -------------------- END
  55. 2017-02-28 22:50:23.211 None INFO WORKFLOW------------ -------------------- Commit data
  56. 2017-02-28 22:50:23.212 None INFO WORKFLOW------------ -------------------- Commit transaction
  57. 2017-02-28 22:50:23.212 None INFO WORKFLOW------------ -------------------- END
  58. 2017-02-28 22:50:33.100 None INFO WORKFLOW------------ -------------------- BEGIN: CWorkflowManager.internal_doWorkItemById :: WorkItemId=6 - ProcId=2 - User=-1
  59. 2017-02-28 22:50:33.100 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: preOperationLoad
  60. 2017-02-28 22:50:33.100 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: beginTransaction
  61. 2017-02-28 22:50:33.100 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: CProcessManager.getProcessInstance
  62. 2017-02-28 22:50:33.100 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: checkForProcessActivation
  63. 2017-02-28 22:50:33.100 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: process.persistProcess
  64. 2017-02-28 22:50:33.100 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: process.ProcessState=Running
  65. 2017-02-28 22:50:33.101 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: process.doWorkItemById(idWorkitem, appEntity, alTransitionIds)
  66. 2017-02-28 22:50:33.101 None INFO WORKFLOW------------ -------------------- activating workitem
  67. 2017-02-28 22:50:33.101 None INFO RULES--------------- -------------------- START EXECUTING RULE True, ID 1000
  68. 2017-02-28 22:50:33.102 None INFO RULES--------------- -------------------- END EXECUTING RULE True, ID 1000
  69. 2017-02-28 22:50:33.102 None INFO WORKFLOW------------ -------------------- Executing transition id=1 Name=Element_2 DisplayName=
  70. 2017-02-28 22:50:33.111 None INFO RULES--------------- -------------------- START EXECUTING RULE True, ID 1000
  71. 2017-02-28 22:50:33.112 None INFO RULES--------------- -------------------- END EXECUTING RULE True, ID 1000
  72. 2017-02-28 22:50:33.112 None INFO WORKFLOW------------ -------------------- Executing transition id=3 Name=Element_3 DisplayName=
  73. 2017-02-28 22:50:33.121 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: postOperationSave
  74. 2017-02-28 22:50:33.121 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: commitTransaction
  75. 2017-02-28 22:50:33.123 None INFO WORKFLOW------------ -------------------- END
  76. 2017-02-28 23:30:07.177 None INFO WORKFLOW------------ -------------------- BEGIN: Create Process Instance
  77. 2017-02-28 23:30:07.178 None INFO WORKFLOW------------ -------------------- Begin transaction
  78. 2017-02-28 23:30:07.178 None INFO WORKFLOW------------ -------------------- Get Process Definition
  79. 2017-02-28 23:30:07.397 None INFO WORKFLOW------------ -------------------- Create Process: 51
  80. 2017-02-28 23:30:07.397 None INFO WORKFLOW------------ -------------------- Set case scope checkPoint
  81. 2017-02-28 23:30:07.741 None INFO WORKFLOW------------ -------------------- BEGIN: Executing task id=4 Name=Event_1 DisplayName=Start on EventTypeOnEnter
  82. 2017-02-28 23:30:07.819 None INFO RULES--------------- -------------------- START EXECUTING RULE True, ID 1000
  83. 2017-02-28 23:30:07.897 None INFO RULES--------------- -------------------- END EXECUTING RULE True, ID 1000
  84. 2017-02-28 23:30:07.897 None INFO WORKFLOW------------ -------------------- Executing transition id=2 Name=Element_1 DisplayName=
  85. 2017-02-28 23:30:07.897 None INFO WORKFLOW------------ -------------------- BEGIN: Executing task id=4 Name=Event_1 DisplayName=Start on EventTypeOnExit
  86. 2017-02-28 23:30:07.897 None INFO WORKFLOW------------ -------------------- END
  87. 2017-02-28 23:30:08.038 None INFO WORKFLOW------------ -------------------- END
  88. 2017-02-28 23:30:08.038 None INFO WORKFLOW------------ -------------------- Commit data
  89. 2017-02-28 23:30:08.147 None INFO WORKFLOW------------ -------------------- Commit transaction
  90. 2017-02-28 23:30:08.147 None INFO WORKFLOW------------ -------------------- END
  91. 2017-02-28 23:30:47.968 None INFO WORKFLOW------------ -------------------- BEGIN: CWorkflowManager.internal_doWorkItemById :: WorkItemId=52 - ProcId=51 - User=-1
  92. 2017-02-28 23:30:47.968 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: preOperationLoad
  93. 2017-02-28 23:30:47.968 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: beginTransaction
  94. 2017-02-28 23:30:47.968 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: CProcessManager.getProcessInstance
  95. 2017-02-28 23:30:47.968 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: checkForProcessActivation
  96. 2017-02-28 23:30:47.968 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: process.persistProcess
  97. 2017-02-28 23:30:47.968 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: process.ProcessState=Running
  98. 2017-02-28 23:30:47.968 None INFO WORKFLOW------------ -------------------- internal_doWorkItemById :: process.doWorkItemById(idWorkitem, appEntity, alTransitionIds)
  99. 2017-02-28 23:30:47.971 None INFO WORKFLOW------------ -------------------- activating workitem
  100. 2017-02-28 23:30:47.972 None INFO RULES--------------- -------------------- START EXECUTING RULE True, ID 1000
  101. 2017-02-28 23:30:47.974 None INFO RULES--------------- -------------------- END EXECUTING RULE True, ID 1000
  102. 2017-02-28 23:30:47.974 None INFO WORKFLOW------------ -------------------- Executing transition id=1 Name=Element_2 DisplayName=
  103. 2017-02-28 23:30:51.254 None INFO CONNECTORS---------- EXTERNALCONNECTORS-- IN0
  104. 2017-02-28 23:30:51.294 None INFO CONNECTORS---------- EXTERNALCONNECTORS-- IN1

Comments (4)

photo
2

Dear Carlos,

In order to create, test and execute a connector, please follow these links:

  1. Overview of our connector documentation: http://help.bizagi.com/bpm-suite/en/index.html?connectors_overview.htm
  2. Create a Connector using our web site: http://help.bizagi.com/bpm-suite/en/index.html?connectors_create.htm and http://help.bizagi.com/bpm-suite/en/index.html?connectors_editor.htm
  3. Execute and Trace your connector using traces: http://help.bizagi.com/bpm-suite/en/index.html?studio_tracingconf.htm and http://help.bizagi.com/bpm-suite/en/index.html?connectors_studio.htm

We look forward to hearing from you

photo
1

Hi, did you find a solution for this?

I am also working with custom connectors and have experienced the same kind of problem. Somethimes the connector just hangs and I do not get any log. Even if the first thing I do in the connector action is writing to log.

photo
1

For anyone reading this:

The problem was the version of npm I was using. Bizagi Studio expects your npm packages to have nested node_modules but npm changed that in v3. If you are developing a custom connector with npm v3+, you should add add a "--legacy-bundling" flag to install your dependencies or simply downgrade to npm v2.

Official npm docs: https://docs.npmjs.com/how-npm-works/npm3

photo
1

Dear Carlos,

Thank you for your comment. It is very helpful.

Regards

photo