Skip to content

Commit ac17e04

Browse files
1 parent 49d2a88 commit ac17e04

File tree

1 file changed

+0
-98
lines changed

1 file changed

+0
-98
lines changed

src/pages/docs/getting-started/setup.mdx

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -42,66 +42,6 @@ When including the SDK from CDN, Ably recommends that you lock into major versio
4242
```
4343
</Code>
4444

45-
### Chrome extension compatibility <a id="chrome-extension"/>
46-
47-
When using ably-js in Chrome extensions, you may encounter CORB (Cross-Origin Resource Blocking) errors, particularly in Chrome 73 and later versions.
48-
49-
#### The problem
50-
51-
Chrome 73+ made changes to how cross-origin requests from content scripts work. Content scripts are now subject to stricter rules than regular page scripts:
52-
53-
- Content scripts don't trigger CORS preflight requests for cross-origin requests
54-
- This causes the main request to be blocked by CORB
55-
- The error typically appears as: `"CORB blocked cross-origin response"`
56-
57-
#### Solutions
58-
59-
**Recommended: Use background script**
60-
61-
The most reliable solution is to run the Ably library in the extension's background script rather than the content script.
62-
63-
**Alternative: Content script with workarounds**
64-
65-
If you need to use the library in a content script, implement these workarounds:
66-
67-
1. **Use WebSocket-only transport** to avoid HTTP requests:
68-
69-
```javascript
70-
const ably = new Ably.Realtime({
71-
key: 'your-api-key',
72-
transports: ['web_socket'] // Avoids XHR transport that triggers CORB
73-
});
74-
```
75-
76-
2. **Implement custom authCallback** for token authentication:
77-
78-
```javascript
79-
const ably = new Ably.Realtime({
80-
authCallback: (tokenParams, callback) => {
81-
// Send message to background script to fetch token
82-
chrome.runtime.sendMessage({
83-
action: 'getAblyToken',
84-
tokenParams: tokenParams
85-
}, (response) => {
86-
if (response.error) {
87-
callback(response.error);
88-
} else {
89-
callback(null, response.token);
90-
}
91-
});
92-
},
93-
transports: ['web_socket']
94-
});
95-
```
96-
97-
3. **Ensure your auth server uses `requestToken`** rather than `createTokenRequest` to avoid additional REST requests from the client.
98-
99-
<Aside data-type="important">
100-
When using authCallback with background script communication, make sure your auth server calls `requestToken` rather than `createTokenRequest`. Otherwise, the library will attempt additional REST requests that may be blocked by CORB.
101-
</Aside>
102-
103-
For more details, see the [Chromium documentation on extension content script fetches](https://www.chromium.org/Home/chromium-security/extension-content-script-fetches).
104-
10545
</If>
10646

10747
<If lang="nodejs">
@@ -165,44 +105,6 @@ repositories {
165105
```
166106
</Code>
167107

168-
### ProGuard configuration <a id="proguard"/>
169-
170-
If you're using ProGuard for code obfuscation in your Java or Android project, you may encounter `ClassNotFoundException` errors when trying to use Ably. This happens because ProGuard may remove classes that are accessed via reflection.
171-
172-
#### The problem
173-
174-
ProGuard obfuscation can remove or rename classes that Ably depends on, particularly:
175-
176-
- Ably internal classes that are accessed dynamically
177-
- Third-party dependencies like MessagePack serialization classes
178-
179-
This typically results in runtime errors such as:
180-
```
181-
ClassNotFoundException: io.ably.lib.transport.ConnectionManager
182-
ClassNotFoundException: org.msgpack.core.MessagePack
183-
```
184-
185-
#### Solution
186-
187-
Add the following keep rules to your ProGuard configuration file (`proguard-rules.pro`):
188-
189-
```proguard
190-
# Keep Ably classes
191-
-keep class io.ably.lib.** { *; }
192-
193-
# Keep MessagePack classes (used by Ably for serialization)
194-
-keep class org.msgpack.core.** { *; }
195-
```
196-
197-
These rules ensure that:
198-
199-
1. **Ably classes**: All classes in the `io.ably.lib` package are preserved, preventing issues with dynamic class loading
200-
2. **MessagePack classes**: Serialization classes used internally by Ably are kept intact
201-
202-
<Aside data-type="note">
203-
If you're using a minimal ProGuard configuration and still encounter issues, you may need to add additional keep rules for other dependencies. Check your ProGuard logs for specific classes that are being removed.
204-
</Aside>
205-
206108
</If>
207109

208110
<If lang="csharp">

0 commit comments

Comments
 (0)