Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix graphql API for clusterproxy setup #19207

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions bbb-graphql-middleware/bbb-graphql-middleware-config.env
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
BBB_GRAPHQL_MIDDLEWARE_LISTEN_PORT=8378
# If you are running a cluster proxy setup, you need to configure the Origin of
# the frontend. See https://docs.bigbluebutton.org/administration/cluster-proxy
# BBB_GRAPHQL_MIDDLEWARE_ORIGIN=bbb-proxy.example.com
5 changes: 5 additions & 0 deletions bbb-graphql-middleware/internal/websrv/connhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
log "github.com/sirupsen/logrus"
"net/http"
"nhooyr.io/websocket"
"os"
"sync"
"time"
)
Expand Down Expand Up @@ -41,6 +42,10 @@ func ConnectionHandler(w http.ResponseWriter, r *http.Request) {
// Add sub-protocol
var acceptOptions websocket.AcceptOptions
acceptOptions.Subprotocols = append(acceptOptions.Subprotocols, "graphql-ws")
bbbOrigin := os.Getenv("BBB_GRAPHQL_MIDDLEWARE_ORIGIN")
if bbbOrigin != "" {
acceptOptions.OriginPatterns = append(acceptOptions.OriginPatterns, bbbOrigin)
}

c, err := websocket.Accept(w, r, &acceptOptions)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { WebSocketLink } from '@apollo/client/link/ws';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import React, { useEffect } from 'react';
import Auth from '/imports/ui/services/auth';
import { Meteor } from 'meteor/meteor';

interface Props {
children: React.ReactNode;
Expand All @@ -15,8 +16,14 @@ const GraphqlProvider = ({ children }: Props): React.ReactNode => {
// const [link, setLink] = React.useState<WebSocketLink | null>(null);
const [apolloClient, setApolloClient] = React.useState<ApolloClient<NormalizedCacheObject> | null>(null);
useEffect(() => {
let GRAPHQL_URL = null;
if ('graphqlUrl' in Meteor.settings.public.app) {
GRAPHQL_URL = Meteor.settings.public.app.graphqlUrl;
} else {
GRAPHQL_URL = `wss://${window.location.hostname}/v1/graphql`;
}
const wsLink = new WebSocketLink(
new SubscriptionClient(`wss://${window.location.hostname}/v1/graphql`, {
new SubscriptionClient(GRAPHQL_URL, {
reconnect: true,
timeout: 30000,
connectionParams: {
Expand Down
12 changes: 12 additions & 0 deletions docs/docs/administration/cluster-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public:
basename: '/bbb-01/html5client'
bbbWebBase: 'https://bbb-01.example.com/bigbluebutton'
learningDashboardBase: 'https://bbb-01.example.com/learning-dashboard'
graphqlUrl: wss://bbb-01.example.com/v1/graphql
media:
stunTurnServersFetchAddress: 'https://bbb-01.example.com/bigbluebutton/api/stuns'
sip_ws_host: 'bbb-01.example.com'
Expand Down Expand Up @@ -185,6 +186,17 @@ Adjust the CORS settings in `/etc/default/bbb-web`:
JDK_JAVA_OPTIONS="-Dgrails.cors.enabled=true -Dgrails.cors.allowCredentials=true -Dgrails.cors.allowedOrigins=https://bbb-proxy.example.org,https://https://bbb-01.example.com"
```

Adjust the CORS setting in `/etc/default/bbb-graphql-middleware`:

```shell
BBB_GRAPHQL_MIDDLEWARE_LISTEN_PORT=8378
# If you are running a cluster proxy setup, you need to configure the Origin of
# the frontend. See https://docs.bigbluebutton.org/administration/cluster-proxy
BBB_GRAPHQL_MIDDLEWARE_ORIGIN=bbb-proxy.example.org
```

Pay attention that this one is without protocol, just the hostname.


Restart BigBlueButton:

Expand Down