24
24
25
25
import java .io .Closeable ;
26
26
import java .io .StringReader ;
27
+ import java .net .URI ;
28
+ import java .net .URISyntaxException ;
27
29
import java .time .Duration ;
28
30
import java .util .ArrayList ;
29
31
import java .util .HashMap ;
51
53
import org .openqa .selenium .json .Json ;
52
54
import org .openqa .selenium .json .JsonInput ;
53
55
import org .openqa .selenium .json .JsonOutput ;
56
+ import org .openqa .selenium .remote .http .ClientConfig ;
54
57
import org .openqa .selenium .remote .http .HttpClient ;
55
58
import org .openqa .selenium .remote .http .HttpRequest ;
56
59
import org .openqa .selenium .remote .http .WebSocket ;
@@ -72,7 +75,7 @@ public class Connection implements Closeable {
72
75
new ConcurrentHashMap <>();
73
76
private final ReadWriteLock callbacksLock = new ReentrantReadWriteLock (true );
74
77
private final Map <Event <?>, List <Consumer <?>>> eventCallbacks = new HashMap <>();
75
- private final HttpClient client ;
78
+ private HttpClient client ;
76
79
private final String url ;
77
80
private final AtomicBoolean isClosed ;
78
81
@@ -90,6 +93,14 @@ boolean isClosed() {
90
93
}
91
94
92
95
void reopen () {
96
+ HttpClient .Factory clientFactory = HttpClient .Factory .createDefault ();
97
+ ClientConfig wsConfig = null ;
98
+ try {
99
+ wsConfig = ClientConfig .defaultConfig ().baseUri (new URI (this .url ));
100
+ } catch (URISyntaxException e ) {
101
+ LOG .warning (e .getMessage ());
102
+ }
103
+ this .client = clientFactory .createClient (wsConfig );
93
104
this .socket = this .client .openSocket (new HttpRequest (GET , url ), new Listener ());
94
105
}
95
106
0 commit comments