Skip to content

Commit

Permalink
Use a different logic when client is not using proxies to connect to …
Browse files Browse the repository at this point in the history
…Gitpod Server when using JetBrains IDEs

Also, use a fixed version on JetBrains backend-plugin to avoid unexpected API changes which could block Werft to build the main branch on Gitpod repository.
  • Loading branch information
mustard-mh authored and felladrin committed Jul 8, 2022
1 parent 308188d commit 132df7a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,37 @@ public GitpodServerConnection listen(
) throws Exception {
String gitpodHost = URI.create(apiUrl).getHost();
HttpClient httpClient;
if (sslContext == null && proxies.size() == 0) {
GitpodServerConnectionImpl connection = new GitpodServerConnectionImpl(gitpodHost);
connection.setSession(ContainerProvider.getWebSocketContainer().connectToServer(new Endpoint() {
@Override
public void onOpen(Session session, EndpointConfig config) {
session.addMessageHandler(new WebSocketMessageHandler(messageReader, jsonHandler, remoteEndpoint));
messageWriter.setSession(session);
client.notifyConnect();
}

@Override
public void onClose(Session session, CloseReason closeReason) {
connection.complete(closeReason);
}

@Override
public void onError(Session session, Throwable thr) {
GitpodServerConnectionImpl.LOG.log(Level.WARNING, gitpodHost + ": connection error:", thr);
connection.completeExceptionally(thr);
}
}, ClientEndpointConfig.Builder.create().configurator(new ClientEndpointConfig.Configurator() {
@Override
public void beforeRequest(final Map<String, List<String>> headers) {
headers.put("Origin", Arrays.asList(origin));
headers.put("Authorization", Arrays.asList("Bearer " + token));
headers.put("User-Agent", Arrays.asList(userAgent));
headers.put("X-Client-Version", Arrays.asList(clientVersion));
}
}).build(), URI.create(apiUrl)));
return connection;
}
if (sslContext == null) {
httpClient = new HttpClient();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pluginUntilBuild=222.*
# See https://jb.gg/intellij-platform-builds-list for available build versions.
pluginVerifierIdeVersions=2022.2
# Version from "com.jetbrains.intellij.idea" which can be found at https://www.jetbrains.com/intellij-repository/snapshots
platformVersion=222-EAP-SNAPSHOT
platformVersion=222.3345-EAP-CANDIDATE-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ class GitpodTerminalService(private val session: ClientProjectSession) {
thisLogger().error("gitpod: Failed to forward port $hostPort from Supervisor's Terminal " +
"${supervisorTerminal.pid}: $reason")
}

override fun onPortForwardingEnded(hostPort: Int) {
thisLogger().info("gitpod: Port $hostPort from Supervisor's Terminal " +
"${supervisorTerminal.pid} is not being forwarded anymore.")
}
}
}

Expand Down

0 comments on commit 132df7a

Please sign in to comment.