File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -704,7 +704,10 @@ export class Client {
704704 }
705705
706706 static async connect ( params : ClientParams , logger ?: Logger ) : Promise < Client > {
707- return new Client ( logger ?? new NullLogger ( ) , params ) . start ( )
707+ return new Client ( logger ?? new NullLogger ( ) , {
708+ ...params ,
709+ vhost : getVhostOrDefault ( params . vhost ) ,
710+ } ) . start ( )
708711 }
709712}
710713
@@ -837,3 +840,5 @@ const extractConsumerId = (extendedConsumerId: string) => {
837840const extractPublisherId = ( extendedPublisherId : string ) => {
838841 return parseInt ( extendedPublisherId . split ( "@" ) . shift ( ) ?? "0" )
839842}
843+
844+ const getVhostOrDefault = ( vhost : string ) => ( vhost === "" ? "/" : vhost )
Original file line number Diff line number Diff line change @@ -46,6 +46,23 @@ describe("connect", () => {
4646 } , 5000 )
4747 } ) . timeout ( 10000 )
4848
49+ it ( "with default vhost as '/' " , async ( ) => {
50+ const [ firstNode ] = getTestNodesFromEnv ( )
51+ client = await connect ( {
52+ hostname : firstNode . host ,
53+ port : firstNode . port ,
54+ username,
55+ password,
56+ vhost : "" ,
57+ frameMax : 0 ,
58+ heartbeat : 0 ,
59+ } )
60+
61+ await eventually ( async ( ) => {
62+ expect ( await rabbit . getConnections ( ) ) . lengthOf ( 1 )
63+ } , 5000 )
64+ } ) . timeout ( 10000 )
65+
4966 it ( "using EXTERNAL auth" , async ( ) => {
5067 client = await createTlsClient ( )
5168
You can’t perform that action at this time.
0 commit comments