no delay broker option check"

This commit is contained in:
2026-07-05 12:25:11 +05:00
parent 45a31c7210
commit 37539469de
5 changed files with 10 additions and 21 deletions

View File

@@ -16,26 +16,6 @@
const wsUrl = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/ws/${cameraId}`;
const player = mpegts.createPlayer(
{ type: 'mpegts', isLive: true, url: wsUrl, hasAudio: false },
{
enableWorker: true, // transmuxing в отдельном треде
enableStashBuffer: true, // включить stash
stashInitialSize: 384,
autoCleanupSourceBuffer: true, // не копить старые буферы в MSE
autoCleanupMaxBackwardDuration: 10,
autoCleanupMinBackwardDuration: 5,
// liveSync — плавное догоняние через playbackRate, а не жёсткий seek
liveSync: true,
liveSyncTargetLatency: 4.0, // target после выравнивания ← дать буферу вырасти
liveSyncMaxLatency: 10.0, // при плохом интернете даём 10с ← не трогать буфер до 10s
liveSyncPlaybackRate: 1.05, // ускорение не более 1.2x ← очень мягкое догоняние
liveBufferLatencyChasing: false, // включить stash ← убрать конфликтующий механизм
lazyLoad: false,
deferLoadAfterSourceOpen: false,
}
);
player.attachMediaElement(document.getElementById('v'))
player.load()

View File

@@ -6,7 +6,12 @@ import { routeMessage } from './router.js'
const mqttUrl = process.env.MQTT_URL as string
export const mqttClient = mqtt.connect(mqttUrl)
export const mqttClient = mqtt.connect(mqttUrl, {
clean: true,
queueQoSZero: false,
reconnectPeriod: 1000,
connectTimeout: 10000,
});
mqttClient.on('connect', () => {
log('mqtt.connected', { url: mqttUrl })

View File

@@ -21,6 +21,7 @@ function getClients(cameraId: string): Set<WebSocket> {
wss.on('connection', (ws: WebSocket, req: IncomingMessage) => {
log(`ws.connection ${req.url}`);
req.socket.setNoDelay(true)
const cameraId = req.url ? lastTopicSegment(req.url) : 'v1';
const clients = getClients(cameraId);

View File

@@ -87,6 +87,7 @@ function handleViewer(ws: WebSocket, channel: string, path: string): void {
wss.on('connection', (ws: WebSocket, req: IncomingMessage) => {
const path = req.url?.split('?')[0] ?? ''
req.socket.setNoDelay(true);
if (path.startsWith('/out/')) {
handleViewer(ws, lastTopicSegment(path), path)

View File

@@ -1,6 +1,8 @@
listener 1883
allow_anonymous true
set_tcp_nodelay true # выключает Nagle на всех сокетах брокера
persistence true
persistence_location /mosquitto/data/