@@ -330,17 +330,23 @@ protected function guessNode($slot)
330330 * Creates a new connection instance from the given connection ID.
331331 *
332332 * @param string $connectionID Identifier for the connection.
333+ * @param CommandInterface|null $command Optional command instance.
333334 *
334335 * @return NodeConnectionInterface
335336 */
336- protected function createConnection ($ connectionID )
337+ protected function createConnection ($ connectionID, CommandInterface $ command = null )
337338 {
338339 $ separator = strrpos ($ connectionID , ': ' );
339340
340- return $ this -> connections -> create ( [
341+ $ config = [
341342 'host ' => substr ($ connectionID , 0 , $ separator ),
342343 'port ' => substr ($ connectionID , $ separator + 1 ),
343- ]);
344+ ];
345+ if ($ command ) {
346+ $ config ['scheme ' ] = $ this ->getConnectionByCommand ($ command )->getParameters ()->scheme ;
347+ }
348+
349+ return $ this ->connections ->create ($ config );
344350 }
345351
346352 /**
@@ -473,7 +479,7 @@ protected function onMovedResponse(CommandInterface $command, $details)
473479 }
474480
475481 if (!$ connection = $ this ->getConnectionById ($ connectionID )) {
476- $ connection = $ this ->createConnection ($ connectionID );
482+ $ connection = $ this ->createConnection ($ connectionID, $ command );
477483 }
478484
479485 if ($ this ->useClusterSlots ) {
@@ -499,7 +505,7 @@ protected function onAskResponse(CommandInterface $command, $details)
499505 [$ slot , $ connectionID ] = explode (' ' , $ details , 2 );
500506
501507 if (!$ connection = $ this ->getConnectionById ($ connectionID )) {
502- $ connection = $ this ->createConnection ($ connectionID );
508+ $ connection = $ this ->createConnection ($ connectionID, $ command );
503509 }
504510
505511 $ connection ->executeCommand (RawCommand::create ('ASKING ' ));
0 commit comments