How to modify websocket message using fiddler

2,428 views
Skip to first unread message

Bruce Han

unread,
Nov 6, 2016, 10:17:23 AM11/6/16
to Fiddler
Hi,

I am using the latest version of fiddler in my window.  I manage to intercept the websocket SEND message which my browser had sent to the server.
I want to modify the json value, such as from DEV to PROD....but is there any UI to do that easily?

SEND
destination:/websocketApp/ws/genAppList/CD944B73007E008E9B03ADD2F3D2A67E
content-length:99

{"environment":"DEV","appVersionNum":"1.1","startViewLabel":"Label1","endViewLabel":"Label2"}

EricLaw

unread,
Nov 7, 2016, 9:29:43 AM11/7/16
to Fiddler
Fiddler's WebSocket View tab does not presently offer the ability to modify the contents of WebSocket Messages as you can with normal HTTP messages in the other inspectors. Instead, you must use the OnWebSocketMessage event handler within your FiddlerScript. E.g. in Rules > Customize Rules you want something like:

static function OnWebSocketMessage(oMsg: WebSocketMessage) {

// Modify a message's content
var sPayload = oMsg.PayloadAsString();
if (sPayload.Contains('"DEV"')) {
    oMsg.SetPayload(sPayload.Replace('"DEV"', '"PROD"');
}                            

}

Gerald Song

unread,
Dec 28, 2016, 10:47:34 PM12/28/16
to Fiddler
I wonder where can I find these documents.
It seems I can't find these on official doc site.

EricLaw

unread,
Dec 29, 2016, 10:04:54 AM12/29/16
to Fiddler
What "documents" are you asking about?

Gerald Song

unread,
Dec 29, 2016, 8:31:15 PM12/29/16
to Fiddler
Fiddler Script.
I can't find things about onWebSocketMessage and WebSocketMessage in http://docs.telerik.com/fiddler/KnowledgeBase/FiddlerScript/ModifyRequestOrResponse or FiddlerScript's ClassView

Eric Lawrence

unread,
Jan 1, 2017, 2:50:06 PM1/1/17
to Fiddler
Unfortunately, the documentation on the docs.telerik.com site hasn't been updated in a long time. It should be present in FiddlerScript's classview; if not, please file an issue in https://fiddler.ideas.aha.io

The FiddlerBook (www.fiddlerbook.com) has the most comprehensive documentation on Fiddler; this forum also has a number of useful threads. The FiddlerCore documentation files are somewhat outdated but you may find them useful anyway; see e.g. https://fiddlerbook.com/om/html/F8192318.htm
Reply all
Reply to author
Forward
0 new messages