Issue with Network.getIpAddressAsync

Hi,

Expo SDK 35. Testing on Android.

When calling getIpAddressAsync(), I get the below error:

[Unhandled promise rejection: Error: Error in creating 
or accessing the socket]
- node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:155:41 in createErrorFromErrorData       
- node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:104:55 in <unknown>
- ... 5 more stack frames from framework internals

Has anyone encountered this error? getNetworkStateAsync works, but same error with getMacAddressAsync.

Thanks

Hey @rly306,

Can you share the full code here as well as let me know the device type, OS version, etc that you are encountering the error on?

Cheers,
Adam

Hey @adamjnav,

Thanks for reaching out. Below are details

Test Device: Samsung S7 Edge
Android Version: 8.0.0
Expo Client version: 2.13.1

Code (Just a test page to see how this Network stuff worked):

import { getIpAddressAsync } from 'expo-network';
import React, { useEffect } from 'react';
import { View } from "react-native";
import { Typography } from "../components/Typography";

export default function AddPowerbar(props) {
    useEffect(() => {
        getIpAddressAsync().then((v) => {
            console.log(v);
        });
    }, []);

    return (
        <View>
            <Typography>Test</Typography>
        </View>
    );
}

Thanks, @rly306. Unfortunately I don’t have my Galaxy S8 handy at the moment but I will test it later tonight. Could you try this Snack joyous turkish delight - Snack and see if anything is different?

If not, would you be able to create a Github Issue with as much relevant information with your Snack as a reproducible example, so we can track this properly?

@adamjnav your snack works fine for me on my Galaxy S8.

1 Like

Thanks. That seems to work on my S7.

What was different though? That code doesn’t look any different than what i had.

Thanks.

Adam wrapped the call to getIpAddressAsync() in an async function.

Hey @wodin/@adamjnav,

So I’m able to replicate that exception above when using a hotspot. Everything works fine with wifi otherwise.

Not a big issue, but i thought I would let you know.

Thanks,
Richard

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.