Issues with CI/CD and websocket authentication

I am trying out the CI/CD options available and create a new branch. Implemented all the changes needed to connect, created a new authentication profile as it is not cloned (You should include that in your guidelines). Everything is working fine except for my websocket it is not authenticated and disconnects when adding a subscription.

I’m using flutter GraphQL library which works fine (with some modifications) when I run from master. I have tried sending the authProfileId with the initial connection but it is not working. Is there something I’m missing here? How do I tell my websocket connection that I’m using a different auth profile?

Thanks
Gummi

Dug a little deeper and it seems to be the workspace id which is incorrect. Tried using the original workspace id with no luck. Tried using the [workspaceid]_[cicd name] as the workspace id with no luck. I have not found any documentation on the shape or form of the workspace id, but the connection string adds _[cicd name] and I assumed the same would apply to the websocket workspace id.

Hello!

I’ve got your problem. I’m considering your issue. I’ll give you a full response soon.

Lada Kokotova | Technical Support Engineer

It’s hard to say for sure what exactly is wrong. Please, could you send me fragments of code where you use subscriptions and where you make an authorization? Also, can you tell me the name of the library you use? These questions will help me find a more personalized solution to your issue.

Lada Kokotova | Technical Support Engineer

I’m using the GraphQL(latest) library for flutter. It works well when I’m working on Master but on another target it gives an error that the workspace is not found. There is an annoying bug in your console that under Settings the ‘Workspace Url’ is not updated and I assume the workspace id as well.

When connecting to the websocket I use the regular url and send as a part of the initial connection the ‘token’ and ‘workspaceId’. This works on master. Below is a code sample I use to connect to your web socket.

static WebSocketLink _socketLinkFrom({
required String url,
required String token,
required String workspaceId,
}) {
final WebSocketLink websocketLink = WebSocketLink(
url,
config: SocketClientConfig(
initialPayload: () async {
return {
‘token’: token,
‘workspaceId’: workspaceId,
};
},
autoReconnect: true,
inactivityTimeout: const Duration(seconds: 3600),
connect: (uri, protocols) => SocketProvider().getSocket(uri, protocols),
),
);

return websocketLink;

}

Returns an error workspace not found. I’m using the following for utls and workspaceId:

url: https://api.8base.com/#######_active
workspaceId: #######_active

Have also tried the workspaceId without the _active stub, does not work.

Thanks
Gummi

Thank you for the update! I’ll check your code and let you know as soon as possible!

Lada Kokotova | Technical Support Engineer

Try passing environment name as a separate parameter in the config

Here’s an example:

config: SocketClientConfig(
  initialPayload: () async {

  return {
    'token': token,
    'workspaceId': workspaceId,
    'environmentName': 'active' // your environment name
    };
},
autoReconnect: true,
inactivityTimeout: const Duration(seconds: 3600),
connect: (uri, protocols) => SocketProvider().getSocket(uri, protocols),
),

Lada Kokotova | Technical Support Engineer

Thanks! This seems to do the trick.

Anytime!

Lada Kokotova | Technical Support Engineer