Implements #123: «disable websocket» settings».

This commit is contained in:
John Livingston 2022-12-08 11:25:57 +01:00
parent 74cf60908e
commit ae5860e537
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
4 changed files with 2402 additions and 4 deletions

View File

@ -99,6 +99,15 @@ If this AppImage is not working, you can fallback to the Prosody that is package
This settings should only be used if the plugin is broken, and waiting for a patch. This settings should only be used if the plugin is broken, and waiting for a patch.
#### Disable Websocket
With Peertube >= 5.0.0, this plugin try to use Websocket connection for chatting.
If the user's browser or connection is not compatible, the browser will automatically fallback on the BOSH protocol.
But in rare case, this can fail. For example if you have a reverse proxy in front of Peertube that does not
allow Websocket connection for plugins.
In this case, you can check this settings to disable Websocket connections.
#### Prosody port #### Prosody port
This is the port that the Prosody server will use. By default it is set to 52800. If you want to use another port, just change the value here. This is the port that the Prosody server will use. By default it is set to 52800. If you want to use another port, just change the value here.

2374
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -44,11 +44,14 @@ async function initWebchatRouter (options: RegisterServerOptionsV5): Promise<Rou
const roomKey = req.params.roomKey const roomKey = req.params.roomKey
const settings = await settingsManager.getSettings([ const settings = await settingsManager.getSettings([
'prosody-room-type', 'prosody-room-type',
'disable-websocket',
'converse-theme', 'converse-autocolors' 'converse-theme', 'converse-autocolors'
]) ])
const boshUri = getBaseRouterRoute(options) + 'http-bind' const boshUri = getBaseRouterRoute(options) + 'http-bind'
let wsUri = getBaseWebSocketRoute(options) // can be undefined let wsUri = settings['disable-websocket']
? undefined
: getBaseWebSocketRoute(options) // can be undefined
wsUri = wsUri !== undefined ? wsUri + 'xmpp-websocket' : '' wsUri = wsUri !== undefined ? wsUri + 'xmpp-websocket' : ''
let room: string let room: string
@ -341,7 +344,7 @@ async function enableProxyRoute (
logger.error( logger.error(
'The http bind proxy got an error ' + 'The http bind proxy got an error ' +
'(this can be normal if you updated/uninstalled the plugin, or shutdowned peertube while users were chatting): ' + '(this can be normal if you updated/uninstalled the plugin, or shutdowned peertube while users were chatting): ' +
(err.message as string) err.message
) )
if ('writeHead' in res) { if ('writeHead' in res) {
res.writeHead(500) res.writeHead(500)
@ -363,7 +366,7 @@ async function enableProxyRoute (
logger.error( logger.error(
'The websocket proxy got an error ' + 'The websocket proxy got an error ' +
'(this can be normal if you updated/uninstalled the plugin, or shutdowned peertube while users were chatting): ' + '(this can be normal if you updated/uninstalled the plugin, or shutdowned peertube while users were chatting): ' +
(err.message as string) err.message
) )
if ('writeHead' in res) { if ('writeHead' in res) {
res.writeHead(500) res.writeHead(500)

View File

@ -222,6 +222,20 @@ Only use this if you encounter problems with the embedded Prosody.`,
default: false default: false
}) })
registerSetting({
name: 'disable-websocket',
type: 'input-checkbox',
label: 'Disable Websocket',
descriptionHTML: `With Peertube &gt;= 5.0.0, this plugin try to use Websocket connection for chatting.
If the user's browser or connection is not compatible, the browser will automatically fallback on the BOSH protocol.
<br>
But in rare case, this can fail. For example if you have a reverse proxy in front of Peertube that does not
allow Websocket connection for plugins.
In this case, you can check this settings to disable Websocket connections.`,
private: true,
default: false
})
registerSetting({ registerSetting({
name: 'prosody-port', name: 'prosody-port',
label: 'Prosody port', label: 'Prosody port',