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 @@ -700,7 +700,10 @@ export class Client {
700700 }
701701
702702 static async connect ( params : ClientParams , logger ?: Logger ) : Promise < Client > {
703- return new Client ( logger ?? new NullLogger ( ) , params ) . start ( )
703+ return new Client ( logger ?? new NullLogger ( ) , {
704+ ...params ,
705+ vhost : getVhostOrDefault ( params . vhost ) ,
706+ } ) . start ( )
704707 }
705708}
706709
@@ -832,3 +835,5 @@ const extractConsumerId = (extendedConsumerId: string) => {
832835const extractPublisherId = ( extendedPublisherId : string ) => {
833836 return parseInt ( extendedPublisherId . split ( "@" ) . shift ( ) ?? "0" )
834837}
838+
839+ 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