diff --git a/test/typescript/typings.ts b/test/typescript/typings.ts index e5eca72f..30ab9dfd 100644 --- a/test/typescript/typings.ts +++ b/test/typescript/typings.ts @@ -9,6 +9,9 @@ const broker = Server({ heartbeatInterval: 60000, connectTimeout: 30000, preConnect: (client: Client, callback) => { + if (client.req) { + callback(new Error('not websocket stream'), false) + } if (client.conn.remoteAddress === '::1') { callback(null, true) } else { diff --git a/types/index.d.ts b/types/index.d.ts index 247949d4..0ebfd6c4 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -7,6 +7,7 @@ import { IPublishPacket, ISubscribePacket, ISubscription, IUnsubscribePacket } from 'mqtt-packet' import { Duplex } from 'stream' import { Socket } from 'net' +import { IncomingMessage } from 'http' import EventEmitter = NodeJS.EventEmitter declare function aedes (options?: aedes.AedesOptions): aedes.Aedes @@ -24,6 +25,7 @@ declare namespace aedes { id: string clean: boolean conn: Socket + req?: IncomingMessage on (event: 'error', cb: (err: Error) => void): this