Skip to content

Commit

Permalink
Fix/base url issue (#193)
Browse files Browse the repository at this point in the history
* fix base url retrieval method

* incorrect base
  • Loading branch information
AjayThorve authored May 1, 2024
1 parent 578b58b commit 10d4f91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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

0 comments on commit 10d4f91

Please sign in to comment.