request.remote_ip with AJAX

Hello everyone. I have a problem with "request.remote_ip" I made an
array:

1 ip = request.remote_ip
2 $ address [ip] = (: test => "OK")
...
...
...
11 ip = request.remote_ip # (along with a lot of AJAX calls)
12 response = $ address [ip] [: test]
It often works, but sometimes it gives me this error:

NoMethodError (undefined method `[] 'for nil: NilClass)
app/controllers/my_controller.rb:12...

and refers to the array. All this happens only when I have A LOT OF AJAX
calls simultaneously. But it is possible that request.remote_ip is
"null" during the AJAX calls? Help me please.

anyone help me?