- if (afb_stub_ws_client_add(stubws, declare_set) < 0) {
- ERROR("can't add the client to the apiset for service %s", apiws->uri);
- goto error3;
+
+ /* open the socket */
+ fdev = afb_socket_open_fdev(uri, 0);
+ if (fdev) {
+ /* create the client stub */
+ stubws = afb_stub_ws_create_client(fdev, api, call_set);
+ if (!stubws) {
+ ERROR("can't setup client ws service to %s", uri);
+ fdev_unref(fdev);
+ } else {
+ if (afb_stub_ws_client_add(stubws, declare_set) >= 0) {
+#if 1
+ /* it is asserted here that uri is never released */
+ afb_stub_ws_client_robustify(stubws, reopen_client, (void*)uri, NULL);
+#else
+ /* it is asserted here that uri is released, so use a copy */
+ afb_stub_ws_client_robustify(stubws, reopen_client, strdup(uri), free);
+#endif
+ return 0;
+ }
+ ERROR("can't add the client to the apiset for service %s", uri);
+ afb_stub_ws_unref(stubws);
+ }