Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/base url issue #193

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/charts/PciThroughputChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const PciThroughputChart: React.FC<IChartProps> = ({ settingRegistry }) => {
// Load settings and initialize WebSocket connection
loadSettingRegistry(settingRegistry, setUpdateFrequency, setIsSettingsLoaded);
useWebSocket<IPCIThroughputProps>(
'nvlink_throughput',
'pci_stats',
false,
updateFrequency,
setPciStats,
Expand Down
10 changes: 7 additions & 3 deletions src/handler.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { URLExt } from '@jupyterlab/coreutils';
import { ServerConnection } from '@jupyterlab/services';

/**
* Connect to a WebSocket API endpoint
*
* @param endPoint WebSocket endpoint for the extension
* @returns A WebSocket object connected to the endpoint
*/
export function connectToWebSocket(endPoint = '') {
const baseUrl = document.location.origin.replace(/^http/, 'ws');
const wsUrl = new URL(`nvdashboard/${endPoint}`, baseUrl);
const settings = ServerConnection.makeSettings();
const baseUrl = settings.baseUrl.replace(/^http/, 'ws');
const wsUrl = URLExt.join(baseUrl, 'nvdashboard', endPoint);

const ws = new WebSocket(wsUrl.href);
const ws = new WebSocket(wsUrl);

ws.onopen = () => {
console.log(`WebSocket connected to ${endPoint}`);
Expand Down
Loading